Android restarts my activity

How can i do this?

when a button is pressed:

mycontext.finish(); 

and then: start over?

+1
source share
1 answer

You can try the following:

 MyActivity.finish() Intent intent = new Intent(MyActivity.this, MyActivity.class); startActivity(intent); 

Or, if that doesn't work, you can do this:

 private boolean isRestarting = false; ... // When button is pressed isRestarting = true; myactivity.finish(); ... // in the onDestroy() method if(isFinishing() && isRestarting){ Intent intent = new Intent(MyActivity.this, MyActivity.class); startActivity(intent); } 
+2
source

All Articles