【发布时间】:2012-03-07 17:52:31
【问题描述】:
我有一个半透明主题的活动:
android:theme="@android:style/Theme.Translucent.NoTitleBar"
这个问题也可以通过这个主题重现:
<style name="MyTheme" parent="@android:style/Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackground">@null</item>
</style>
此活动在启动时加载并保存在内存中(当我启动此活动时,我将 FLAG_ACTIVITY_REORDER_TO_FRONT 标志作为额外的广告)。
问题:当我(从菜单)开始这个活动时,活动没有出现,什么也没有发生。 但是:如果我删除半透明主题:一切正常,活动将回到前面。
是 onNewIntent() 被调用。
如果我按下半透明的活动是下面的活动!但它必须是顶级的。
一个例子
A(半透明活动)B C
堆栈:A
A startActivity(B)
堆栈:A,B
B startActivity(C)
堆栈:A、B、C
c startActivity(A) // 带有标志 FLAG_ACTIVITY_REORDER_TO_FRONT
堆栈应该是:B,C,A
但是 A 永远不会被带到前面,尽管它的 onNewIntent() 被调用了。
有什么想法吗?
附注
有趣的未回答问题:http://groups.google.com/group/android-developers/browse_thread/thread/269c67f6b39cfe45?pli=1
不想使用singleTask 或singleInstance 中的android:launchMode。这些会更改后台堆栈并将活动移动到自己的堆栈中。因此,我们不再有 A、B、C。
singleTask 和 singleInstance — 不适合大多数人 应用程序,因为它们产生的交互模型很可能 对用户不熟悉并且与大多数其他人非常不同 应用程序。
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
任何想要直观表示launchModes的人都可以试试这个应用程序:https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode
【问题讨论】:
-
是的,重复了你的场景 android 2.3
-
检查是否在
onNewIntent()中获得Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT标志 -
onNewIntent()接收FLAG_ACTIVITY_REORDER_TO_FRONT -
我认为它按预期工作.. 将窗口背景设置为透明,它不会对眼睛可见.. 如果看到快照会很清楚..
-
大约一年半前,有人在Android开发者群发了similar problem。仍然没有回复
标签: android android-intent android-activity stack transparency