ActivityNotFoundException?

I’ve had this issue too, as perfectly concisely described by jpahn.

the period at the front did not give any help to me.

even with exactly this (a copy of the original question including edits), I would still get ActivityNotFoundException.

Main.java

Intent intent = new Intent();
 intent.setAction("com.test.app.TEST");
 startActivity(intent); // ActivityNotFoundException

Manifest.xml

<activity android:name=".MainActivity" android:theme="@android:style/Theme.Dialog">
    <intent-filter>
        <action android:name="com.test.app.TEST" />
    </intent-filter>
</activity>

This was resolved, after much trial-and-error, by simply adding this to the intent-filter in the manifest:

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

So the final manifest file contained:

<activity android:name=".MainActivity" android:theme="@android:style/Theme.Dialog">
    <intent-filter>
        <action android:name="com.test.app.TEST" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

Leave a Comment