我有一个半透明主题的 Activity :
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>
此 Activity 在启动时加载并保存在内存中(当我启动此 Activity 时,我将 FLAG_ACTIVITY_REORDER_TO_FRONT
标志添加为额外的)。
问题:当我(从菜单)开始这个 Activity 时, Activity 没有出现,什么也没有发生。 但是:如果我删除半透明主题:一切正常, Activity 将回到前面。
是 onNewIntent() 被调用。
如果我按下半透明的 Activity 是下面的 Activity !但它必须是顶级的。
一个例子
A ( translucent activity) B C
Stack: A
A startActivity(B)
Stack: A,B
B startActivity(C)
Stack: A,B,C
c startActivity(A) // with flag FLAG_ACTIVITY_REORDER_TO_FRONT
Stack should be: B,C,A
but A is never brought to the front, although its onNewIntent() is called.
有什么想法吗?
附注
有趣的未回答问题:http://groups.google.com/group/android-developers/browse_thread/thread/269c67f6b39cfe45?pli=1
不想使用
singleTask
或 singleInstance
的 android:launchMode
。这些会更改后台堆栈并将 Activity 移动到自己的堆栈中。因此,我们不再有 A、B、C。
singleTask and singleInstance — are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications.
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
任何想要直观表示launchModes的人都可以试试这个应用程序:https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode
最佳答案
如果我们不从AndroidManifest.xml中设置主题,在setContentView之前设置activity block并设置主题,在第一个半透明activity的onCreate方法中,问题就解决了,代码如下:
public class TranslucentActivityDemoActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setTheme(R.style.myTheme);
setContentView(R.layout.main);
}
关于android - 错误 : Theme. 半透明和 FLAG_ACTIVITY_REORDER_TO_FRONT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9309479/