[英]How to clear the stack activities without clearing the root activity, and bring the root activity to front?
I searched a lot of threads and implemented a lot of solutions but I think I want something else. 我搜索了很多线程并实现了很多解决方案,但我想我还需要其他东西。 Suppose I have A->B->C->D activities.
假设我有A-> B-> C-> D活动。 From activity DI wont to go to the same instance of A and also clear D,C,B activities.
从活动DI不会转到A的相同实例,也不会清除D,C,B活动。 I want to resume activity A and not recreate it!
我想恢复活动A,而不要重新创建它! How can I do that?
我怎样才能做到这一点? But remember, I want also to clear all the other activities, so I in the stack I should have only activity A.
但是请记住,我还想清除所有其他活动,所以在堆栈中我应该只有活动A。
Thank you! 谢谢! :)
:)
just do on back button , Try to call your intent with the flag "BROUGHT TO FRONT" 只需在后退按钮上执行操作,尝试使用标志“ BROUGHT TO FRONT”调用您的意图
Intent intent = new Intent(this,A.class);
intent .setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
startActivity(intent );
Assuming activity 'A' is the root of the task of your application - Using the flag CLEAR_TASK along with NEW_TASK will portray the same behaviour as yours. 假设活动“ A”是应用程序任务的根源-将标志CLEAR_TASK与NEW_TASK一起使用将描绘与您的行为相同的行为。 All you need to do is add these flags in the intent for activity 'A'.
您需要做的就是将这些标志添加到活动“ A”的意图中。
The flag CLEAR_TASK will remove all the activities on top on 'A' and NEW_TASK will create a new task with 'A' (same activity instance) as its root. 标志CLEAR_TASK将删除“ A”顶部的所有活动,而NEW_TASK将创建一个以“ A”(相同活动实例)为根的新任务。
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.