'Changing Activity sequence in Android Studio
I am working on a project, I have three activities. Each time I run the project, After the Splash Screen,Login Screen should show then MainActivity. How do I define the sequence here.
Manifest file:
<activity
android:name=".Splash"
android:exported="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Login"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Solution 1:[1]
The manifest file has nothing to do with the order. You need to put your logic to open activities. For example, in splash screen activity, you can open Login Screen
val intent = Intent(this, LoginActivity::class.java)
startActivity(intent)
In your login screen when user press on login button you can do
button.setOnClickListener {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Skylek |
