我怎样才能做到这一点?
How can I do that?
按钮点击:
mycontext.finish();
和则:再次启动
您可以尝试两种这样的:
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);
}