每次用户打开应用程序时,我们使用启动画面来显示公司标志。目前,我们将启动画面显示3秒。
以下是代码:
private static int SPLASH_TIME_OUT = 3000; // Delay of 3 Seconds
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
Intent i = new Intent(SplashScreenActivity.this, AnotheActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
但是这个启动画面的持续时间只是团队随意选择的。我们知道,在Android应用程序生态系统中,启动画面通常并不被鼓励使用,但由于这是我们应用程序的需求,因此它被实现了。
我的问题:有没有关于选择正确的启动画面持续时间的标准Android指南/最佳实践?
yourHandler.removeCallbacksAndMessages(null)
,以确保在启动画面时用户退出应用程序后不会启动以下活动。 - Abhijit