Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
2015-10-29 19:07
856 查看
首先做成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
参考三个链接:
http://blog.csdn.net/jiangwei0910410003/article/details/23940445http://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-start-up-my-apphttp://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser
相关文章推荐
- Eclipse Android 代码自动提示功能
- 《iOS总结》上传报错:ERROR ITMS-90049
- android启动模式对activity的影响
- Android 动画之ScaleAnimation应用详解
- appium for windows 环境搭建
- Android 我的第一个 NDK 程序 (AndroidStudio)
- Android把多个控件定义成一个整体的布局类使用
- Android Studio 加载 .so库出现couldn't find "*.so"
- iOS 中常用的几种函数 (向上,向下,四舍五入)取整, 总算是理解了
- 【Android Studio】jacoco导致cannot find local variable
- Android App的签名打包(晋级篇)
- android签名机制
- 怎么导入vitamio并能在自己的程序中使用
- Android5.0系统:Material风格以及DrawerLayout抽屉效果
- Android中判断用户多次连续点击
- Android Studio/Gradle构建太慢解决办法
- v3 igrimace 安装方法,平安易贷 微信陌陌 uber 滴滴打车
- iOS判断用户当前设备型号iPhone-model
- Fragment间的信息传递
- iOS 时间操作