How can I do that?
on button click:
mycontext.finish();
and 开发者_如何学JAVAthen: start again?
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);
}
精彩评论