Magnus Söderlund Magnus Söderlund - 3 years ago 74
Android Question

Android application dropping behind the view visible before start on "up" navigation

I have an application that allows the user to select from several different themes. In this application i've created a custom dialog-like activity with semi-transparent background by adding the following code to all my themes:

<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="windowContentOverlay">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/semi_transparent_background</item>

I am using ActionBarSherlock 4.1 (old version to be able to force overflow menu on older versions of the OS).

Everything around this works fine. But since i've added this another issue has been noticed.
On a device or simulator running 4.4.2 when ever i use the up navigation, my app falls behind the view that was visible before starting the application and all navigation is now affecting that view and not my application. I have to use the app drawer utility to get back to my application again.

Back navigation works perfect.

This is the code snippet for the up navigation, directly from the Android "providing up navigation" article:

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
return true;
return super.onOptionsItemSelected(item);

This is the code where i start a new activity:

findViewById( View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(StartPageActivity.this, OpeninghoursActivity.class);

If i remove these two:

<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">false</item>

Everything is back to normal except that my transparent activity is not transparent any longer.

This does not happen on emulated 4.2.2 and 4.3 devices. Any ideas on a work around?

Answer Source

Check your manifest and see if you've set the activity launchmode to singleTask:

<activity android:name=".TestActivity" 

But this is most definitely a bug in Android 4.4.2 since it's not reproducible on earlier versions

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download