Sorry if this question has been asked before . What I am trying to do is when app starts splash screen appear and after 3 second My mainactivity runs . but when I press back button it returns me again on splash screen . So my question is how can I control the flow of activity so that it should not come again to splash screen below is my
manifest file
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
And if there are lots of activity and i want my mainactivity to be parent activity and if user is on parent activity and user press back then splash screen should not appear . Is there a way to do that through manifest
You have to finish SplashActivity.
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
finish();
The Simplest solution is: set android:noHistory="true" in manifest.xml
<activity android:name=".SplashScreen"
android:noHistory="true"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With