在Android中重载Activity是一个很好的做法吗?

最好的方法是什么?这一点。完成,然后这个。用Intent启动activity ?


当前回答

以一个相同的活动开始,并关闭该活动。

Intent refresh = new Intent(this, Main.class);
startActivity(refresh);//Start the same Activity
finish(); //finish Activity.

其他回答

我需要在我的一个应用程序中更新消息列表,所以我只是在关闭我所在的对话框之前刷新了我的主UI活动。我相信还有更好的方法来实现这一点。

// Refresh main activity upon close of dialog box
Intent refresh = new Intent(this, clsMainUIActivity.class);
startActivity(refresh);
this.finish(); //

在尝试了一段时间后,我发现重新启动一个活动并没有意想不到的后果。此外,我认为这与Android在改变方向时默认做的事情非常相似,所以在类似的情况下我没有理由不这样做。

在活动中,您可以调用rebuild()来“重新创建”活动(API 11+)

我用过这个,不用它也能正常工作 完成()

startActivity(getIntent());

以一个相同的活动开始,并关闭该活动。

Intent refresh = new Intent(this, Main.class);
startActivity(refresh);//Start the same Activity
finish(); //finish Activity.