gpt4 book ai didi

java - 如何在 8 秒内完成 Ads_Fullscreen Activity 并在之后执行 MainActivity?

转载 作者:行者123 更新时间:2023-12-02 10:07:17 24 4
gpt4 key购买 nike

闪屏的两种情况

  1. 如果启用广告,则启动屏幕时间将为 2 秒,Ads_Fullscreen 时间将为 8 秒,然后将出现最终的主要 Activity 。

  2. 如果未启用广告,则启动屏幕时间将为 5 秒,然后将出现主要 Activity 。

这是启动屏幕的代码

 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);

最佳答案

将默认 SPLASH_TIME_OUT 设置为 5000 毫秒。

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);

关于java - 如何在 8 秒内完成 Ads_Fullscreen Activity 并在之后执行 MainActivity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55258163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com