Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the startup activity in android?

Tags:

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.

like image 229
hemanth kumar Avatar asked Jun 27 '11 06:06

hemanth kumar


People also ask

How does Android know which activity to run first?

Unlike programming paradigms in which apps are launched with a main() method, the Android system initiates code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle.

How do I make another activity as main activity?

If you want to make Login activity your main activity then put the the intent-filter tag inside Login activity. Any activity your want to make your main activity must contain intent-filter tag with action as main and category as launcher.

What is launcher activity in Android?

Launcher Activities are the activities that can be launched for a given intent. For example, when you press an app icon on the home screen, the StartActivity intent starts the activity you have specified as the launcher activity.


1 Answers

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

<activity android:name=".Main"           android:label="@string/app_name">     <intent-filter>         <action android:name="android.intent.action.MAIN" />         <category android: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.

like image 85
achie Avatar answered Sep 28 '22 05:09

achie