2010-06-25 42 views
2

也許我誤解了如何Intent s和intent-filter s工作,但在我看來,這應該是一個簡單的例子。但是,它不起作用。意圖對象不觸發意圖過濾器

這裏是我發送意圖:

Intent i = new Intent(Intent.ACTION_VIEW); 
i.setType("vnd.android.cursor.item/vnd.connectsy.event"); 
startActivity(i); 

這裏是意圖過濾器:

<activity android:name=".events.EventView"> 
    <intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 
     <data android:mimeType="vnd.android.cursor.item/vnd.connectsy.event" /> 
    </intent-filter> 
</activity> 

最後,錯誤我recieving:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=vnd.android.cursor.item/vnd.connectsy.event } 

回答

4

Here's the answer

的Android對待傳遞給startActivity(),就好像它們 包含至少一個類別中的所有隱式意圖 : 「android.intent.category.DEFAULT」(即 CATEGORY_DEFAULT常數)。因此, 願意接收 隱式意圖的活動必須包含 「android.intent.category.DEFAULT」 他們的意圖過濾器。

添加

<category android:name="android.intent.category.DEFAULT" /> 

到你的意圖過濾器在AndroidManifest.xml