创建一个(具有相同活动的)新实例时,我希望删除/删除一个旧的活动实例,但是我需要将所有其他活动保留在后栈中(因此FLAG_ACTIVITY_CLEAR_TOP不够用).
I'm looking to delete/remove an old activity instance when a new instance (of same activity) is created, however I need to maintain all other activities in back-stack (therefore FLAG_ACTIVITY_CLEAR_TOP won't suffice).
例如说我有活动A,B和C. 我开始:A-> B-> C->B. 在第二个B活动开始时,我需要删除现有的B活动. 因此,我现在有:A-> C-> B正在运行...
E.g. say I have activities A, B & C. I start: A -> B -> C -> B. On the start of the second B activity I need to remove the existing B activity. Therefore I now have: A -> C -> B running...
任何帮助表示赞赏.
推荐答案删除活动似乎并不像我想象的那么容易,因此,这不是一个完整的答案,但我将继续使用FLAG_ACTIVITY_REORDER_TO_FRONT.这不会杀死现有活动,而是将其移到堆栈顶部.
It seems that deleting the activity is not as easy as I would have imagined therefore not a complete answer but I'm going to go with using FLAG_ACTIVITY_REORDER_TO_FRONT. This will not kill the existing activity but instead move it to top of stack.
Intent intent = new Intent(ctx, Activity.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent);这将允许上面概述的活动导航.
This will allow for the activity navigation outlined above.
如果有人知道清除实际活动的方法,我仍然很感兴趣.
I'm still interested if someone knows of a means to clear the actual activity.
更多推荐
开始新活动时删除旧的活动实例
发布评论