Nitin Dominic
Nitin Dominic

Reputation: 2719

Is Intent responsible for launching MainActivity of he application?

If Activity manager launches the MainActivity through intent-filter with action=main, and category=launcher, then which type of intent is used?

I'm confused little bit. Is it implicit intent?

Upvotes: 2

Views: 361

Answers (3)

Balwant Kumar Singh
Balwant Kumar Singh

Reputation: 1178

When the user selects your app icon from the Home screen, the system calls the onCreate() method for the Activity in your app that you've declared to be the "launcher" (or "main") activity. This is the activity that serves as the main entry point to your app's user interface.

You can define which activity to use as the main activity in the Android manifest file, AndroidManifest.xml, which is at the root of your project directory.

The main activity for your app must be declared in the manifest with an intent-filter that includes the MAIN action and LAUNCHER category(That you know probably).

If a component does not have any intent filters, it can receive only explicit intents. A component with filters can receive both explicit and implicit intents.

Therefore, activities that are willing to receive implicit intents must include "android.intent.category.DEFAULT" in their intent filters. Filters with "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" settings are the exception. They mark activities that begin new tasks and that are represented on the launcher screen. They can include "android.intent.category.DEFAULT" in the list of categories, but don't need to.

For more details please refer this link: http://developer.android.com/guide/components/intents-filters.html

Upvotes: 1

Sahil Mahajan Mj
Sahil Mahajan Mj

Reputation: 11141

An intent is an abstract description of an operation to be performed. Its most significant use is in the launching of activities.

when the user clicks on the application icon, the android system looks in the manifest file for the intent with

action="android.intent.action.MAIN"

and

category="android.intent.category.LAUNCHER".

MAIN action is the main entry point of the application.

LAUNCHER category means it should appear in the Launcher as a top-level application.

Upvotes: 2

piotrpo
piotrpo

Reputation: 12636

Intent is just a piece of information about intention. Intent do not starts anything. It just inform OS that there is a need to do something (i.e start app). System looks for apps able to resolve this intention, starts them and pases to them starting intent (becouse you can pass some portion of data in it).

When user clicks app icon in launcher, launcher application generates and sens intent to OS (with explicit name of desired application to start). Android creates separate DVM, main activity class, starts acrivity's life cycle with calling onCreate() and brings activity to foreground.

Upvotes: 1

Related Questions