Reputation: 6196
I am using implicit way to start an Activity
. But when it runs, LogCat shows me can not find the Activity
.
here is my declare of <intent-filter>
:
<activity android:name=".GroupEditActivity">
<intent-filter>
<action android:name="android.intent.action.EDIT"></action>
<data mimeType="vnd.android.cursor.item/group"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
Here is the code to start Activity
:
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType(Groups.CONTENT_ITEM_TYPE);
startActivity(intent);
Reference said if I set the type and action the same as Intent-filter
, them my Activity
can start up. But when I only set action in Intent
, it still can start the Activity
which Intent-filter
contains mimetype. So I totally lost.
here is what i find in official website:
Thanks
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDITtyp=vnd.android.cursor.item/group }
And I can sure the type and action in java and xml are the same.
I solve the problem myself. The error is cause by <data mimeType
. I forgot to add android here. So if change to <data android:mimeType
, then everything works fine. But why it doesn't report a exception before, does mimeType is also legal?
Upvotes: 1
Views: 177
Reputation: 111
Are you launching an activity separate from the main activity? In this case you need to call the name of that activity. If you're trying to launch your main activity, it doesn't need to call an intent.
Intent intent = new Intent(this, MyOtherActivity.class);
startActivity(intent);
Upvotes: 1