I intended to start new activity "B" in my Android app from the first activity "A." Both of them have classes that I've created. However, I receive the runtime error: programme has terminated suddenly, try again when I use the following code to start B. This is my code:
Intent myIntent = new Intent(this, AddNewActivity.class);
startActivity(myIntent);
The application only functioned when I added a new entry for activity B to AndroidManifest.xml/manifest/application/activity/intent-filers.
I have two inquiries.
- How does Android decide which activity to start first when there are many entries for one activity in AndroidManifest.xml?
- I was unable to comprehend intent-filters. Could someone kindly explain.
This is a portion of my AndroidManifest.xml.
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ListAllActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddNewActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>