Original: Android Development portal activity
How does the portal for Android Development Activityadnroid app determine entry activity?
Is it because class is called mainactivity, the layout file is called Activity_main.xml?
If you think so, it's a big mistake.
It is possible to determine the entry activity because it is configured in the application's manifest file, and the system is established based on the application's manifest file (androidmanifest.xml).
How to establish, what is the mark?
Let's take a look at the list file and see at a glance:
By the way, the system can be established because of the intent filter of the Red line callout Intent-filter
The system accesses all intent-filter in the manifest file until the following code is found:
<action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />
Depending on the name of the activity in which it is located, find the entity class of activity that needs to be started.
So can we define two entry activity?
The answer is yes. Let's try it again, create a new activity, name secondactivity, register the activity in the manifest file, and set its intent filter as the primary activity.
:
In addition, we will find an interesting phenomenon:
Is it found that launching an app generates two icons, yes, each entry activity will generate an icon corresponding to it.
When we click on the test icon, we will enter the mainactivity, but we will enter the secondactivity when we click on the secondactivity icon, that is to say, an application has two entrances, which is obviously not good, we should strictly stipulate that There is only one entry activity, do not want to act wonderful!!!
Android Developer Portal activity