Android重启我的活动

时间:2010-11-27 14:59:44

标签: android android-context

我该怎么做?

点击按钮

mycontext.finish();

然后:再次开始?

1 个答案:

答案 0 :(得分:3)

你可以试试这个:

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

如果这不起作用,你可以这样做:

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);
}