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>
There two types of intents in android framework, 1-Implicit intents that you are using,
just add one line in intent filter
2- Explicit Intents
startActivity(i);
To be safe you can also call your new activity like this:
However, you must add the activity to the androidmanifest - and write a . in front of it, e.g.
Add a . (dot) before your activity name in Android Manifest. So it should be android:name=".WordsToSpeakMainActivity"
I have some addition to the @Tom Pace answer. The answer is completely right, but to make it more clear:
ActivityNotFoundException
occurs because of absence ofBecause when Android OS see this in the manifest file, understands that this activity can receive intent.
The point
ActivityNotFoundException
thrown is that, when activity(intent-creator-activity) tries to create intent for other activity(intent-receiver-activity), Android OS sees there is intent for receiver activity but receiver activity does not receive anyone. Then Android OS returns null or empty intent to intent-creator-activity. AndstartActivity
throws that exception.I have found a code from android developers to avoid this exception:
Android Developers: Intent Filters
I found a solution to this problem... I´m using 2 modules in a android studio project, the thing here is that I needed to add the activity to the main manifest file
I had that in the unity activity manifest, I just copied the activity and paste it in the main manifest and that was it, hope it helps, eve been struggling a lot with this for the past 3 weeks
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
Manifest.xml
This was resolved, after much trial-and-error, by simply adding this to the intent-filter in the manifest:
So the final manifest file contained: