Problem Description
I have two activities in my application MainActivity and BannerActivity. From the main activity I start BannerActivity in onCreate method. But I first I see MainActivity screen for a second and then BannerActivity screen.
Question
How I can do so that BannerActivity will be shown first and after countdown timer will stop and BannerActivity will close after that MainActivity come to the screen.
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);
}
};
BannerActivity
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();
}
};