45

We mention android.intent.action.MAIN and android.intent.category.LAUNCHER as Intent filter of the launcher activity in the Manifest.xml. What is imp. of these two? What are their functionality?

4 Answers 4

36

From the docs:

category -- Gives additional information about the action to execute. For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level application, while CATEGORY_ALTERNATIVE means it should be included in a list of alternative actions the user can perform on a piece of data.

MAIN means that this activity is the entry point of the application, i.e. when you launch the application, this activity is created.

Sign up to request clarification or add additional context in comments.

6 Comments

What will happen if I mention this intent-filter block twice?
Seems like the first one to be declared will be the main, but seems like undefined behavior for me. Interesting though...
Two activities with same intent filters, then the user is notified to select the correct activity. - dev_andriod
What does top-level application launcher mean?
Answering @Xegara it refers to the screen where your app icons appear and you launch one of them
|
21

MAIN action is the main entry point of the application.

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

1 Comment

but what about shortcutManager, you also use Intent.ACTION_MAIN for other activities to add as shortcuts to home screen, so which activity is main then?
2

MAIN : will start the activity home.This activity will be the Home page of the application.

CATEGORY_LAUNCHER : The activity can be the initial activity of a task and is listed in the top-level application launcher.

Comments

1

MAIN: the activity is the main entry point to the application i.e., the first activity to start when application starts

LAUNCHER: the activity will appear in top-level application launcher (where app icons appear and user can launch one of them).

Additionally, If two activites in an application have MAIN and LAUNCHER, then two icons will start appearing in top-level application launcher. Where each icon corresponds to each app activity

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.