<activity android:name="ApiDemos"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
-Can any one explain about main, default and launcher what are the use of those properties in manifest for activity if used more than 1 activity in my project?
MAIN matches all of the activities that can be used as top-level entry points into an application. The LAUNCHER category says that this entry point should be listed in the application launcher. The default category is required for the Context.
The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
On latest Android versions - If there are more than one launcher activities and if we don't put this category tag then the activity which is mentioned first in the Android manifest file will get launched as start-up activity.
A MANIFEST file is an XML document that describes the manifest, or package contents, of a Windows software application. It is used by various Windows technologies for configuring and deploying software, including ClickOnce and the Common Language Runtime (CLR). MANIFEST files are often seen with the compound ".exe.
android.intent.action.MAIN matches all of the activities that can be used as top-level entry points into an application.
The LAUNCHER category says that this entry point should be listed in the application launcher.
The default category is required for the Context.startActivity()
method to resolve your activity when its component name is not explicitly specified.
So category LAUNCHER + action MAIN
let the icon for this Activity show up in the launchers list of available "applications".
You can have this intent-filter
on more than one Activity in your AndroidManifest.xml
and all of them will show up in the list off "applications".
Intents are documented here and IntentFilters here.
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