问题描述
我的应用程序中有两个活动MainActivity
,BannerActivity
. 从主要活动开始,我从BannerActivity
方法开始onCreate
。但我首先看到MainActivity
屏幕一秒钟然后BannerActivity
屏幕。
问题
我如何做到这一BannerActivity
点将首先显示,倒数计时器将停止并在屏幕出现BannerActivity
后关闭。MainActivity
主要活动
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/* Show banner activity for several seconds then close it. */
Intent bannerIntent = new Intent(MainActivity.this, BannerActivity.class);
this.startActivity(bannerIntent);
}
};
横幅活动
public class BannerActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
/* Make banner fullscreen. */
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_banner);
/* Launch count down timer for several seconds. */
CountDownTimer countDownTimer = new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) { /* Not used. */ }
@Override
public void onFinish() {
BannerActivity.this.finish();
}
}.start();
}
@Override
public void onBackPressed() {
/* Lock back button presses. */
super.onBackPressed();
}
};