I want to restart my activity
without the help of buttons, I want it to restart automatically in a while. How do I do this?
I want to restart my activity
without the help of buttons, I want it to restart automatically in a while. How do I do this?
To restart a Activity
you can use the recreate () , available from API 11.
Make this Activity recreated with a new instance. This results in the same flow when Activity is created due to a configuration change - the current instance will go through its lifecycle to onDestroy (), and a new instance will be created later.
Completing Zulian's response, you can put this code in the creation of Activity:
new CountDownTimer(RESTART_TIME, 1000) {
public void onTick(long millisUntilFinished) {}
public void onFinish() {
recreate();
}
}.start();