I am getting an ActivityNotFoundException
in the following code:
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>
At the very top of your AndroidManifest.xml, you'll see the package attribute
and then, in the activity tag, you'll see the name attribute:
Make sure that the package name and activity name, when joined together, make the full package specification of your Activity i.e.
com.android.example
+.Something
=com.android.example.Something
Otherwise, you'll get a
ActivityNotFoundException
.I got this error after moving an activity class from one package to another. Clean build solved it (Project -> Clean).
To launch an activity by a string definition, use:
Be sure to declare your activity in the manifest.xml within the aplication:
To start the new Activity:
Where main stands for the current activity,