1

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

logcat details:

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?

2
  • 2
    Please post the logcat output also. Nov 21, 2011 at 8:47
  • But isn't android.intent.action.EDIT' the same with Intent.ACTION_EDIT`? Nov 21, 2011 at 9:11

1 Answer 1

1

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);
1
  • Yes, this is explicit way to start activity. Using this method, system will not consult intent-filter and start the specific activity directly. But what i want now is start a activity in a implicit way. Nov 21, 2011 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.