Android的活动启动 [英] Android activity restart
本文介绍了Android的活动启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有在重新启动一个活动一片混乱。我有两个功能非常适用于相同的任务。请指导我哪一个是最好的,为什么?
I am having a confusion in restarting an activity.. I have two function that works well for the same task. Please guide me which is best and why?
public void restart()
{
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(R.anim.fade,R.anim.fade);
startActivity(intent);
}
或
public void restart()
{
onCreate();
}
在此先感谢?
Thanks In advance?
推荐答案
我觉得这是对你的要求,更清洁的方式。
I think this is a cleaner way for your requirement.
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
这篇关于Android的活动启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文