开发者

Android restart my activity

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜