I have 2 activity_main but when I give it run it raises me first as I change it for the second

1

Hello friends I am new to android, I would like you to help me how to tell android that I will have the second activity not the first one.

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Where I would change this is my android manifest

    
asked by Kevin Quevedo 14.04.2018 в 01:44
source

1 answer

-1

Define the appropriate intent-filter within your AndroidManifest.xml file so that the Activity you want is the first to load, in this case this would be the intent-filter :

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

For example, if you want me to start MainActivity2 , remove it from MainActivity and assign it to MainActivity2 :

<activity android:name=".MainActivity">
</activity>
<activity android:name=".MainActivity2">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

in this way MainActivity2 would be the first Activity to be loaded from your application.

To be more specific this would be the change in your AndroidManifest.xml :

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity android:name=".MainActivity">
    </activity>

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

</application>
    
answered by 14.04.2018 в 01:48