Android:从HOME重新启动后保留任务的活动堆栈
我的应用程序有两个活动,我按以下顺序启动:
HOME > A > B
现在我按 HOME 并再次启动“A”。我希望在“A”顶部看到活动“B”,但我得到的是“A” - 因此活动堆栈被清除。
明示:
<activity android:name=".activity.A" android:label="A" android:alwaysRetainTaskState="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.B" android:label="B">
<intent-filter>
</intent-filter>
</activity>
我该怎么办?
My application has two activities, that I start in this order:
HOME > A > B
Now I press HOME and launch "A" again. I would like to see activity "B" on a top of "A", but instead I get "A" - so the activity stack is cleared.
Manifest:
<activity android:name=".activity.A" android:label="A" android:alwaysRetainTaskState="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.B" android:label="B">
<intent-filter>
</intent-filter>
</activity>
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现出了什么问题...
配置是正确的,但是我从 Eclipse 启动了应用程序进行调试,这就是问题所在。
案例#1。
案例#2。
案例#3。
I figured out what is wrong...
The config is right, but I started application for debugging from Eclipse, this was the issue.
Case # 1.
Case # 2.
Case # 3.
我们发现这是一个已知的 Android 问题 - 已在此处<进行了正式跟踪/a> 和此处。
尽管他们说(没有检查)它已在 ADT Eclipse 插件的 0.9.6 版本中修复,但我仍然可以在应用程序 OTA 升级期间在真实设备上看到这一点。至少 Android 1.6、2.0.1、2.1 和 2.2 会发生这种情况。
我们已经为这个问题创建了一个解决方法。请查看此处。
We have discovered this is a known Android issue - it has been officially tracked here and here.
Despite they say (did not checked) it has been fixed in the 0.9.6 release of the ADT Eclipse plugin I still can see this on a real device during the application OTA upgrade. At least this happens for Android 1.6, 2.0.1, 2.1 and 2.2.
We've created a workaround for this issue. Check it out here.
事情没那么复杂。您只需要操纵清单即可。
AndroidManifest.xm
了解“android:exported”& 'android:alwaysRetainTaskState'在这里:
android:exported
< a href="http://developer.android.com/guide/topics/manifest/activity-element.html#always" rel="nofollow">android:alwaysRetainTaskState
It's not that complex. You just need to manipulate the manifest.
AndroidManifest.xm
Read about the 'android:exported' & 'android:alwaysRetainTaskState' here:
android:exported
android:alwaysRetainTaskState