我想知道如何在 Activity 之间轻松切换。例如,在我的应用程序中,我有:
Activity 1 -> Activity 2 -> Activity 3 -> Activity 4 -> Activity 5
如何从 Activity 5 返回 Activity 2,同时保持 Activity 2 的状态?当我尝试开始一个新 Intent 时,我失去了 Activity 2 中的状态和额外内容...
public void onClick(DialogInterface view, int button) {
switch (button) {
case DialogInterface.BUTTON_POSITIVE:
Intent i = new Intent(activity,AccueilFournisseur.class);
activity.startActivity(i);*/
break:
}
非常感谢您的帮助
最佳答案
您应该阅读Tasks and Back Stack和 Managing the Activity Lifecycle 。您可以更改 Activity 的启动模式,但我认为最好保持启动模式不变。将您的状态保存在 Activity.onPause() 中方法和恢复在 Activity.onResume() .
关于java - 在 Activity 之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6801382/