Android的重新启动我的活动 [英] Android restart my activity
本文介绍了Android的重新启动我的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能做到这一点?
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);
}
这篇关于Android的重新启动我的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文