-2

Can any one exactly explain the difference between

 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />

And why when we remove any one of the above my app doesn't run or we are not able to run our app.

Ankita Singh
  • 304
  • 3
  • 17
  • 1
    Have you checked [Android action.MAIN and category.LAUNCHER function](http://stackoverflow.com/questions/6288744/android-action-main-and-category-launcher-function) ? – Ravi Nov 03 '16 at 12:35
  • I was asking this bcoz i thought u didn't get my question or wat ? – Ankita Singh Nov 03 '16 at 12:47
  • yeah i know but is there any example where we can see the use of both or can we use these terms individually ? – Ankita Singh Nov 03 '16 at 12:50

4 Answers4

1

They aren't differents code, they make a part of the same tag, called <intent-filter>. You can put this part of code in any other activity, that you want the app starts.

Rodrigo Paixão
  • 246
  • 5
  • 12
1

MAIN action means all of the activities that can be used as top-level entry points into an application.It does not require any other information in the Intent i.e. it does not receive any input data to start.

LAUNCHER category says that entry point should be listed in the application launcher.

Like can there is any example where we can use only one of them :

There can be more than one activity with main action and Launcher. But if we are defining more than one activity in Launcher category then we have to use attribute android:taskAffinity="", which specify the exact package and Activity to be started.

Awadesh
  • 3,530
  • 2
  • 20
  • 32
1

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.

Parth Patel
  • 118
  • 1
  • 1
  • 10
0

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.

Mahesh Sehajpal
  • 246
  • 2
  • 6