与标志FLAG_ACTIVITY_CLEAR_TOP(机器人)活动 [英] Activity with Flag FLAG_ACTIVITY_CLEAR_TOP (android)
问题描述
我已经堆了一个接一个推出的活动。
但在活动中的一个,我需要推出特定活动,旗 FLAG_ACTIVITY_CLEAR_TOP
。
I have stack of activities launched after one another.
but in one of the activity I need to launch that particular activity with flag FLAG_ACTIVITY_CLEAR_TOP
.
所以,这将完成所有的previous活动开始。
So that it will finish all the previous activities and start.
问题我面对,我不希望完成从堆栈中它应该是在新推出的活动,回到presence活动之一。
Problem I am facing that i don't want to finish one of the activity from the stack it should be presence on back of the newly launched activity.
假设我有活动 [A] [B] [C] [D]
我开始研究[D]
,旗活动 FLAG_ACTIVITY_CLEAR_TOP
开始活动后研究[D]
它会破坏所有的活动,我想活动 [B]
来保持在后面跑,当我们preSS返回键上研究[D]
它应该显示活动 [B]
。
Suppose I have activities [A] [B] [C] [D]
I am starting [D]
activity with flag FLAG_ACTIVITY_CLEAR_TOP
after starting activity [D]
it will destroy all the activities, I want activity [B]
to be kept running on the back and when we press back key on [D]
it should display activity [B]
.
如何做到这一点?
谢谢,
PP。
Thanks,
PP.
推荐答案
就像@Mudassir说,开始活动[A]。当你调用[b]简单地使用标志来清除所有数据,[B],然后你可以从[B]调用[D]。无标志;因而具有[B] [D]像你想要的吗?然后对后退按钮preSS你会从[D]。为[B],而无需任何其它数据?你似乎不以为他要你打电话的研究[D] [B],旗,和什么的这样做的目的是什么?你会风与刚刚[B]在这一点上。
Like @Mudassir said, start activity [A]. When you call [B] simply use the FLAG to clear all data but [B], and then you can call [D] without flag from [B];thus having [B][D] like you wanted? Then on back button press you will go from [D] to [B], without having any other data?. You seem to not be thinking he wants you to call [B] with flag from [D], and what would the purpose of that be? You'd wind up with just [B] at that point.
-Either方式,你失去[C]前进的道路上。一个解决方案可能是:
-Either way, you lose [C] along the way. A solution might be:
startActivity(A)
[in activity A] startActivity(B) - WITH CLEAR_TOP TO KILL [A]
[in activity B] startActivityForResult(C) - WHEN [C] IS finish() IT WILL COME BACK TO [B]
[in activity B, onActivityResult()] startActivity(D)
这会给你只是[B]放大器; [D]。同时还获得到[C] ....试试吧,它会工作
This will give you JUST [B]&[D] while still getting to [C]....try it, it will work.
这篇关于与标志FLAG_ACTIVITY_CLEAR_TOP(机器人)活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!