android – How to specify which activity starts on app launch?-ThrowExceptions

Exception or error:

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?

How to solve:

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>

###

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>

###

You need to make changes in AndroidManifest.xml file…

<application
        android:icon="@drawable/image"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name="define the activity which you want to start first here" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



        <activity android:name=".FirstActivity" >
        </activity>
        <activity android:name=".SecondActivity" >
        </activity>
        <activity android:name=".ThirdActivity" >
        </activity>
    </application>

Hope this will help you….

###

In your AndroidManifest.xml put the following:

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *