Android(安卓)浏览器中启动自定义应用
By Felix
Use an <intent-filter>
with a <data>
element. For example, to handle all links to twitter.com, you'd put this inside your <activity>
in your AndroidManifest.xml
:
<intent-filter> <data android:scheme="http" android:host="twitter.com"/> <action android:name="android.intent.action.VIEW" /> </intent-filter>
Then, when the user clicks on a link to twitter in the browser, they will be asked what application to use in order to complete the action: the browser or your application.
Of course, if you want to provide tight integration between your website and your app, you can define your own scheme:
<intent-filter> <data android:scheme="my.special.scheme" /> <action android:name="android.intent.action.VIEW" /> </intent-filter>
Then, in your web app you can put links like:
<a href="my.special.scheme://other/parameters/here">
And when the user clicks it, your app will be launched automatically (because it will probably be the only one that can handle my.special.scheme://
type of uris). The only downside to this is that if the user doesn't have the app installed, they'll get a nasty error. And I'm not sure there's any way to check.
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer