I have an activity with the translucent Theme :
android:theme="@android:style/Theme.Translucent.NoTitleBar"
Also the problem is reproduceable with just this Theme:
<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>
This activity is loaded at startup and kept in memory (when I start this activity, I ad the FLAG_ACTIVITY_REORDER_TO_FRONT
flag as extra).
Problem : when I start this activity (from the menu), the activity don't show up, nothing happens. But : if I remove the translucent theme : all works fine, the activity is back to front.
Yes onNewIntent() is called.
And if I press back the translucent activity is the one below! But it needs to be the top.
An example being
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.
Any ideas?
Side notes
Interesting unanswered question: http://groups.google.com/group/android-developers/browse_thread/thread/269c67f6b39cfe45?pli=1
android:launchMode
of singleTask
or singleInstance
are not wanted to be used. These change the backstack and move activities into their own stack. Therefore we don't have A,B,C any more.
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
Anyone who wants a visual representation of launchModes try this app : https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode
If we do not set the theme from AndroidManifest.xml, activity block and set the theme before setContentView, in onCreate method in the first translucent activity, the problem is solved, below is the code:
public class TranslucentActivityDemoActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setTheme(R.style.myTheme);
setContentView(R.layout.main);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With