This code is for my splash screen Activity:
@Override
protected void onResume() {
super.onResume();
handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
}
}, 5000);
}
When I click the device back button ,MainActivity become finish and again SplashActivity comes to up,and again it's onResume method get call, problem is here that handler doesn't execute again and MainActivity doesn't start again after 5 second ! I want it execute again!
what's the problem and what should i do?
thanks for attention.
I modified your code a little bit check this
@Override
protected void onResume() {
super.onResume();
new android.os.Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
}
}, 5000);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With