Each Activity
, BroadcastReceiver
, and Service
in your AndroidManifest.xml
has an Intent Filter that specifies how it interacts with the Android Environment. For example, BroadcastReceivers can specify what broadcast events it is listening to.
Activities can specify things like how they are seen in the home screen, or what files extensions can be opened in the app. Some apps don't have Activities or Intent Filters - and just use Services and BroadcastReceivers. If an app does use one or more Activities, the developer can optionally add the Intent Filter - but this is not required. If the user wants to provide a launcher for the user to be able to open the app, he or she must use this Intent Filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This will create a launcher with the application icon (or an activity icon if it is overridden with the android:icon
attribute) and the name of the activity (specified by the android:label
attribute). So for example, I could have a manifest like this:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".OtherActivity"
android:label="@string/other_title"
android:icon="@drawable/ic_other_launcher" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
This manifest states that there are two launcher Activities - MainActivity
and OtherActivity
. They have different icons and different names. They are also completely separate Activity - so each one will have to handle receiving new intent, just as you would any other Activity.
So, to answer your question - there isn't necessarily a main or first Activity, and there could be multiple main or first Activities.
Also keep in mind that first Activity may be configured changing an Activity's launch mode. By default each newly launched Activity would be a new instance of the same app - and would have separate back stacks rooted at the Activity that first opened via the Intent Filter.