Skip to content Skip to sidebar Skip to footer

How To Change The Startup Activity In Android?

I have two activities namely login and calendar in my Application. Currently my startup activity is 'calendar'. I want to run the login as first activity not calendar.

Solution 1:

The startup activity [Launcher Activity] is declared in the projects' AndroidManifest.xml file

Look for that activity tag in the manifest which looks like this

<activityandroid:name=".Main"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity>

Look at the attribute android:name. Main is the class which is launched when the app starts. Currently your calendar activity name should be there. Change that to the .classpath of your activity that you want to launch.

That should do it. You may also want to do the hello world application in the tutorials and go through the docs a little to see how Android Applications work.

Solution 2:

Add Intent filter to the Activity in which you want startup. In your case Modify the AndroidManifest.xml file as follows

<activityandroid:name=".login"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter>

Solution 3:

remove the intent-filter code from calendar Activity tag in manifest and add it to the Activity you wanna load first

<intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter>

I mean paste it in the activity you like to run as default.

<activityandroid:name="com.example.gridviewimages.AnotherActivity"android:label="@string/app_name" ><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity>

Where as

From the docs

category -- Gives additional information about the action to execute. For example, 

CATEGORY_LAUNCHER means it should appear in the Launcher as atop-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.

Solution 4:

You want the Application element of the Android Manifest file. You can see details here. Look at the name attribute, this points to the Application class.

Post a Comment for "How To Change The Startup Activity In Android?"