0

In my new android sudio project I created two activities. The first is the MainActivity and the second is called SecondActivity. The second is more like a sort of menù. Logically, when the app starts, SecondActivity must appear as first.

In the manifest I declared both the activities but I don't know how to declare them correctly so that SecondActivity appears as the first activity in the application after I loaded it on my Android device.

This is my project's manifest :

<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=".SecondActivity"> </activity>
    </application>
St69
  • 111
  • 7

4 Answers4

1

Did you tried this, my friend

<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=".SecondActivity"> 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
Sangeeth Nandakumar
  • 1,362
  • 1
  • 12
  • 23
0

Two options...

1) Move the intent filter.

2) Switch the android:name property since ordering does not matter

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
0

Try this:

<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=".SecondActivity"> <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

The intent-filter tag let you choose trough the action wich activity will be the main.

Jonathan Aste
  • 1,764
  • 1
  • 13
  • 20
0

Simply move the intent filters to the second activity like so:

...

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

...

The parts between the intent-filter tags (<intent-filter> and </intent-filter>) tell Android that this activity should be used when the launcher icon of your app is pressed (i.e. the initial activity).

Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125