问题
Two situation for Splash Screen
if ads is enable then Splash Screen time will be 2 seconds and Ads_Fullscreen time will be 8 seconds then final Main Activity will come.
if ads is not enable then Splash Screen time will be 5 seconds and then Main Activity will come.
This is code for splash screen
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i;
if (prefManager.isFirstTimeLaunch()){
i = new Intent(SplashScreen.this,WelcomeActivity.class);
prefManager.setFirstTimeLaunch(false);
}else if(bn_bstatus.equals("enable")) {
i = new Intent(SplashScreen.this,Ads_Fullscreen.class);
}else{
i = new Intent(SplashScreen.this,MainActivity.class);
}
startActivity(i);
finish();
}
},SPLASH_TIME_OUT);
回答1:
set default SPLASH_TIME_OUT as 5000 milliseconds.
public final int SPLASH_TIME_OUT = 5000;
For SplashScreen Activity
final Intent intent;
if (ads.enable()) {
intent = new Intent(SplashScreen.this, WelcomeActivity.class);
prefManager.setFirstTimeLaunch(false);
} else if (bn_bstatus.equals("enable")) {
intent = new Intent(SplashScreen.this, Ads_Fullscreen.class);
SPLASH_TIME_OUT = 2000;
} else {
intent = new Intent(SplashScreen.this, MainActivity.class);
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(intent);
finish();
}
}, SPLASH_TIME_OUT);
For Ads_Fullscreen Activity
SPLASH_TIME_OUT = 8000;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// start MainActivity
}
}, SPLASH_TIME_OUT);
来源:https://stackoverflow.com/questions/55258163/how-to-finish-the-ads-fullscreen-activity-in-8-seconds-and-lunch-the-mainactivit