Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify which activity starts on app launch?

Tags:

I have an app with 3 different activities in it. When I launch the app one of the activities always starts first. But I want a differnt activity to start before the one that is currnetly starting first.

How would I change this to make a differnet activity start first?

like image 830
alexward1230 Avatar asked Mar 14 '12 03:03

alexward1230


People also ask

Where would we specify which activity should launch first in app?

The intent-filter inside the activity tells Android which Activity to launch.

How do you start an activity only once the app is opened for the first time?

It is important to check that the first activity which opens when the app is launched is MainActivity. java (The activity which we want to appear only once). For this, open the AndroidManifest. xml file and ensure that we have the intent-filter tag inside the activity tag that should appear just once.


2 Answers

Open your AnroidManifest.xml file and set the Launching Activity using the intent-filter tag as follows,

    <activity android:name=".LaunchingActivity"         android:label="@string/app_name">         <intent-filter>             <action android:name="android.intent.action.MAIN" />             <category android:name="android.intent.category.LAUNCHER" />         </intent-filter>     </activity> 
like image 96
Lucifer Avatar answered Oct 07 '22 08:10

Lucifer


You need to add an intent filter to the activity you want to start on application launch in your app's AndroidManifest.xml:

<intent-filter>     <action android:name="android.intent.action.MAIN" />     <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> 
like image 36
Tyler Treat Avatar answered Oct 07 '22 08:10

Tyler Treat