问题
How can I do that?
on button click:
mycontext.finish();
and then: start again?
回答1:
You could try either this:
MyActivity.finish()
Intent intent = new Intent(MyActivity.this, MyActivity.class);
startActivity(intent);
Or if that doesn't work, you could 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);
}
来源:https://stackoverflow.com/questions/4292224/android-restart-my-activity