Android 浏览器跳转App
来源:互联网 发布:女仆咖啡厅 网络剧 编辑:程序博客网 时间:2024/05/05 10:58
参考文章
点击打开链接
点击浏览器中的URL链接,启动特定的App。
首先做成HTML的页面,页面内容格式如下:
<a href="[scheme]://[host]/[path]?[query]">启动应用程序</a>
这一句就可以了。
各个项目含义如下所示:
scheme:判别启动的App。 ※详细后述
host:适当记述
path:传值时必须的key ※没有也可以
query:获取值的Key和Value ※没有也可以
作为测试好好写了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">启动应用程序</a>
接下来是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下内容。(启动Activity时给予)
※必须添加项
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="myapp" android:host="jp.app" android:pathPrefix="/openwith"/> </intent-filter>
HTML记述的内容加入<data …/>。
其中必须的内容仅scheme,没有其他内容app也能启动。
※注意事项:intent-filter的内容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】这2个,不能与这次追加的内容混合。
所以,如果加入了同一个Activity,请按以下这样做,否则会导致应用图标在桌面消失等问题。
<intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="myapp" android:host="jp.app" android:pathPrefix="/openwith"/> </intent-filter>
这样的话,没有问题。
接下来在Activity中需要取值的地方添加以下代码,我是直接写在OnCreate函数里的:
String action = i_getvalue.getAction();
if(Intent.ACTION_VIEW.equals(action)){
Uri uri = i_getvalue.getData();
if(uri != null){
String name = uri.getQueryParameter("name");
String age= uri.getQueryParameter("age");
}
}
这样就能获取到URL传递过来的值了。
0 0
- Android 浏览器跳转App
- android app小白试水-fragment跳转浏览器debug
- Android 点击浏览器链接 跳转app并传值
- Android中跳转浏览器
- android app 跳转到微信
- Android两个App跳转
- android app跳转到微信
- 用浏览器跳转APP研究方案记录
- 由浏览器跳转到自己的app
- DeepLink(浏览器点击链接跳转到app)
- 手机app中跳转调用外部浏览器
- Android 跳转到其他APP/浏览器时,返回键和列表键无法使用
- 阻止 android webview 中的链接跳出APP(即跳转到系统浏览器)
- 浏览器打开android app
- Android浏览器打开app
- Android浏览器调用APP
- android 跳转浏览器测试代码
- Android跳转浏览器打开URL
- JavaSe基础(1)-- 基本概念
- map常用操作
- [数据存储之七]CoreData操作练习
- NYOJ-123-士兵杀敌(四)
- 文章标题
- Android 浏览器跳转App
- J - Assign the task(dfs序+线段树)J
- js 文本框键盘输入事件
- 程序员编写技术文档的新手指南
- HDOJ 2011 多项式求和
- Linux入门
- java中API文档开头内容解释一下?
- 栈的应用——实现简易计算器(一)
- JFinal+amazeUI+beetl+layer+shiro+poi+restful+handlebars初认识