我遇到问题。荫使用下面的代码来interupt链接到我的应用程序作为指向我的应用的链接
<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="http" android:host="twitter.com"/>
<data android:scheme="http" android:host="facebook.com"/>
</intent-filter>
但问题是,我需要在运行时也就是我可以添加或删除在运行时,主机设置数据方案和主机。所以请有人帮助我设定数据方案,并在runtime.I主机的价值正在使用下面的代码,但它不工作
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.VIEW");
filter.addCategory("android.intent.category.DEFAULT");
filter.addCategory("android.intent.category.BROWSABLE");
filter.addDataScheme("http");
filter.addDataAuthority("www.facebook.com", null);
RecieveBroadcaster receiver = new RecieveBroadcaster();
registerReceiver(receiver, filter);
可以请一个人帮我 – saba 2012-03-06 10:08:38
我已经得到了这个答案,所以如果有人需要帮助。 ACTION.VIEW是一项活动操作。因此我们无法将其注册到广播接收器。由于意图过滤器不能在运行时设置(除了广播接收器的情况)。而广播接收机可以只重播像android.intent.action.PHONE_STATE这样的广播动作。因此注册ACTION> VIEW是不允许的,广播接收者将永远不会对其做出响应。 – saba 2012-03-07 10:13:21