I am new to Android development I seen lots of tutorial where they have only android.intent.action.MAIN
which is basically a start activity of the application.
But, in the android app demos, I have seen multiple android.intent.action.MAIN
statements in mainfest.xml. Can anyone explain why the mainfest.xml
has multiple android.intent.action.MAIN
statements?
And, in which scenarios we are supposed to have multiple MAIN
s in manifest.xml?
They're different entry points into the program. For instance, I just created two activities, both of which had the typical intent filter
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
It turns out that my launcher screen now has two different icons for the same program, one for each different activity. This makes sense, since the MAIN/LAUNCHER intent filter essentially tells android that the activity is the app's starting activity. Nothing in android's intent filter model forces each app to have one and only one starting activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With