2
我遇到問題。我需要中斷不是靜態的鏈接,但用戶將在運行時創建所有鏈接。所以我在運行時創建了我的intentfilter對象。所以當我使用清單文件中的代碼時它工作。但在java類中使用它並不適用於我。下面的代碼IntentFilter在創建運行時時不起作用
這不是工作
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_VIEW);
filter.addCategory(Intent.CATEGORY_DEFAULT);
filter.addCategory(Intent.CATEGORY_BROWSABLE);
filter.addDataAuthority("www.facebook.com", null);
filter.addDataScheme("http");
RecieveBroadcaster receiver = new RecieveBroadcaster();
registerReceiver(receiver, 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="http" android:host="twitter.com"/>
<data android:scheme="http" android:host="facebook.com"/>
</intent-filter>
http://stackoverflow.com/questions/2230280/capturing-home-intent-programmatically此鏈接可能有幫助 – Triode 2012-03-06 05:10:35
可能重複的[interupting鏈接到我的應用程序](http://stackoverflow.com/questions/9579447/interupting鏈接到我的應用程序內) – Luksprog 2012-03-06 07:23:45