In my android app, I wanted to start an activity 'B' from initial activity 'A'. I have created classes for both of these. However when using following code to start B, I get runtime error as application has stopped unexpectedly, try again
.
Intent myIntent = new Intent(this, AddNewActivity.class);
startActivity(myIntent);
When I added a new entry in AndroidManifest.xml/manifest/application/activity/intent-filers for activity B then the application worked.
I have two questions:
- When there are multiple activities entries in AndroidManifest.xml, how does android know which activity to start first?
- I could not understand intent-filters. Can anyone please explain.
Here is my partial 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>