我希望我的应用程序在用户单击链接时启动,例如,http://myapp.com
该链接嵌入在 SMS 消息中。
我遵循了这个[解决方案],但它对我不起作用。模拟器每次都打开浏览器。
这是意图过滤器:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.catagory.DEFAULT"/>
<category android:name="android.intent.catagory.BROWSABLE"/>
<data android:host="myapp.com" android:scheme="http" />
</intent-filter>
我还尝试增加意图过滤器的优先级,以便在浏览器使用android:priority = 100
标签之前拦截意图,但它没有改变任何东西。所以要么这个优先级不够高,要么意图过滤器从一开始就没有匹配。
这是点击链接后系统广播的意图。它给出了:
04-27 13:03:22.905: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.VIEW dat=http://myapp.com cmp=com.android.browser/.BrowserActivity}
我的猜测是,每次发送此意图时,Android 都会选择默认浏览器。我想知道是否与 cmp 属性有关。我们可以改变它吗?不然怎么能在浏览器之前拦截到intent呢?
任何建议都会受到欢迎。先感谢您 :)