本文介绍了如何调用Android的previous活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序5活动,Act1-> Act2-> Act3-> Act4-> ACT5

I have five activity in my app,Act1->Act2->Act3->Act4->Act5,

所有活动在一个方向去,因为我在上面已经指出, 现在我要再次呼吁ACT2圆满完成我ACT5的任务之后,因此它的工作好,我展示了ACT2(我已经使用了 startActivity(callIntent)在ACT5带我ACT2再次), 在此之后,当我点击早在ACT2按钮,我有ACT1(我在ACT2再次向我展示ACT1使用 startActivity(callIntent))的我想要什么? ..但问题是,当我点击ACT1的后退按钮它打算把我在ACT2。但我想从那里离开,因为ACT1是第一个初始的活动。

All activity goes in single direction as I have stated above, Now I have to call again Act2 after successful completion of my Act5's task, so its working good and showing me the Act2 (I have Used startActivity(callIntent) in Act5 for showing me Act2 again), After this when I click on Back button in Act2, I have Act1 (I have Used startActivity(callIntent) in Act2 for showing me Act1 again) its what I want .....But the problem is that when I click Act1's back button it is going to put me on Act2. But I want to exit from there, because Act1 is the first initial activity.

我如何设置聚焦,而不是建立意向我隐藏的活动,并调用startActivity。

How Can I set focus to my hidden activity , instead of creating Intent and call startActivity.

你知道吗?请大家帮帮忙。

Any idea? Please help.

推荐答案

长期研究,我得到了退栈的pretty的太多的了解在一个应用程序的所有活动后。

After long research I got pretty much understanding of "back stack" for all the activities in an app.

每一次我移动到另一个活动,也为我所用开幕previous活动 Intent.startActivity()标志FLAG_ACTIVITY_NEW_TASK ,所以我有新的活动增加了回栈每一次。

Each time I moved to another activity and also for opening previous activity I have used Intent.startActivity() with flag FLAG_ACTIVITY_NEW_TASK, So every time I have new activity added in the "back-stack".

我已经试过意向标志为 FLAG_ACTIVITY_CLEAR_TOP 同时使用调用previous活动由回栈 Intent.startActivity()和我回叫previous活动的解决方案,并清除所有的堆栈之上调用一个活动顶。所以,现在的后退按钮不会工作很好,因为我需要的。

I have tried intent flag as FLAG_ACTIVITY_CLEAR_TOP while calling previous activity from "back-stack" using Intent.startActivity() and I got the solution of calling back the previous activity and clears all stack top activity above the calling one activity. So now back button does working nice as I needed.

让看到我的呼唤previous活动的问题, A =活性; A1-> A2-> A3->一张A4> A5-> B2 ,现在如果你点击后退按钮,你将有A1的活动,并单击A1的后退按钮后,又有B2活动这是后A5等调用。

Let see My problem of calling previous activity ,A = activity; A1->A2->A3->A4->A5->B2 , now if you click on back button you will have A1 activity , and after clicking on A1's back button you have again B2 activity which was called after A5 and so on.

使用A5活动,并再次呼吁A2的 FLAG_ACTIVITY_CLEAR_TOP 后(没有创造新的活动,但调用precious一个)我有以下的情况。

After using the FLAG_ACTIVITY_CLEAR_TOP in A5 activity and called again A2 (Not creating new activity but calling precious one) I have following situation.

A = activity; A1->A2->A3->A4->A5

调用previous A2的活性,而且我有以下的情况。 A1-> A2

calling previous A2 activity, and I have following scenario.A1->A2 only.

感谢。

这篇关于如何调用Android的previous活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:19