回到previous屏幕,而无需创建新实例 [英] Go back to previous screen without creating new instance
问题描述
作为图像解释,流量是这样的。所以每当上标识的按钮活动用户点击被调用。作为简单的解决方案,我们可以用这种方法...
As explained in image, flow is something like this. So whenever user click on logo button Activity A should be called. As simple solution we can use this method...
Intent intent = new Intent(activity, activityToStart);
startActivity(intent);
但这种活动将创造我的应用程序的新活动。但我需要调用该活动的同一个实例,我们流程图中前进。活动从A到B,然后再打开B能很容易地通过调用完成()
但是从活动C或D,怎么回来到A
But this activity will create a new activity for my app. but I need to call the same instance of the activity as we move forward in flow diagram. from Activity A to B and then again on B can be called easily by callingfinish()
but from Activity C or D, how to come back to A.
我运行的想法,但没有得到任何卓见成效。请帮助我,如果你有任何建议或任何地方,我错了。先谢谢了。
I am running out of ideas but not getting any fruitful result. Please help me if you have any suggestion or at any place i am going wrong. Thanks in advance.
推荐答案
要由D回来给A,使用意向的标志。
To Come Back from D to A, use Intent Flags.
Intent intent = new Intent(activity, activityToStart);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intent);
FLAG_ACTIVITY_CLEAR_TOP,会而不是创建新的活动,它会调用堆栈上的活动,并会弹出所有的活动在被调用的活动。
FLAG_ACTIVITY_CLEAR_TOP, will instead of creating new activity, it will invoke the activity on the stack, and will pop all the activities over the activity being invoked.
这篇关于回到previous屏幕,而无需创建新实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!