我遇到問題。蔭使用下面的代碼來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