views:

174

answers:

1

Perhaps I'm misunderstanding how Intents and intent-filters work, but it seems to me that this should be a strait-forward case. However it's not working.

Here is the Intent I'm sending:

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

And here is the intent-filter:

<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>

And finally, the error I'm recieving:

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

Here's the answer:

Android treats all implicit intents passed to startActivity() as if they contained at least one category: "android.intent.category.DEFAULT" (the CATEGORY_DEFAULT constant). Therefore, activities that are willing to receive implicit intents must include "android.intent.category.DEFAULT" in their intent filters.

Add

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

to your intent filter in AndroidManifest.xml

Gawcio