安卓:在launchMode =&QUOT的bug; singleTask"? - >活动堆栈不是preserved [英] Android: bug in launchMode="singleTask"? -> activity stack not preserved

查看:116
本文介绍了安卓:在launchMode =&QUOT的bug; singleTask"? - >活动堆栈不是preserved的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要活动 A 有载安卓launchMode =singleTask在清单中。现在,每当我开始另一个活动从那里,如: B 和preSS的主页按钮在手机上返回到主屏幕,然后再回去我的应用程序,或者通过pressing应用程序的按钮或pressing的主页按钮长,以显示我最近的应用程序它并不preserve我的活动栈和直返回到 A 而不是预期的活动 B

My main activity A has as set android:launchMode="singleTask" in the manifest. Now, whenever I start another activity from there, e.g. B and press the HOME BUTTON on the phone to return to the home screen and then again go back to my app, either via pressing the app's button or pressing the HOME BUTTONlong to show my most recent apps it doesn't preserve my activity stack and returns straight to A instead of the expected activity B.

下面两种行为:

Expected: A > B > HOME > B
Actual: A > B > HOME > A (bad!)

有我缺少一个设置或这是一个错误?如果是后者,是有一种解决方法,直到错误是固定的吗?

Is there a setting I'm missing or is this a bug? If the latter, is there a workaround for this until the bug is fixed?

FYI:这个问题已经讨论过了<一href="http://groups.google.com/group/android-developers/browse_thread/thread/9af9165ae679d337">here.但是,它似乎并不认为有任何真正的解决办法,但。

FYI: This question has already been discussed here. However, it doesn't seem that there is any real solution to this, yet.

推荐答案

这是不是一个错误。当现有 singleTask 活动启动后,它上面的所有其他活动的堆栈将被破坏。

This is not a bug. When an existing singleTask activity is launched, all other activities above it in the stack will be destroyed.

在preSS 首页并再次启动活动, ActivityManger 调用的意图

When you press HOME and launch the activity again, ActivityManger calls an intent

{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]flag=FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_RESET_IF_NEEDED cmp=A}

所以,结果是A> B>首页> A。

So the result is A > B > HOME > A.

这是不同的,当A的launchMode是标准。它包含一个任务将走到前台,并保持状态和以前一样。

It's different when A's launchMode is "Standard". The task which contains A will come to the foreground and keep the state the same as before.

您可以创建一个标准的活动,例如。 C为C的onCreate方法的发射器和startActivity(A)

You can create a "Standard" activity eg. C as the launcher and startActivity(A) in the onCreate method of C

只是删除​​ launchMode =singleTask,并设置 FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP 标记时调用的意图,A

Just remove the launchMode="singleTask" and set FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP flag whenever call an intent to A

这篇关于安卓:在launchMode =&QUOT的bug; singleTask&QUOT;? - &GT;活动堆栈不是preserved的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆