NullPointerException
NullPointerException

Reputation: 37681

Immersive Full Screen Mode (Sticky flag) disabled when i open a spinner

I am using Inmersive Full Screen mode with Sticky flag modality, the fourth of these four modalities explained here: https://developer.android.com/training/system-ui/immersive.html

I am doing this:

    if( Build.VERSION.SDK_INT >= 19 ){      
        //si es mayor o igual a API 19 kitkat ocultamos las barras UI del sistema
        mainBody.setSystemUiVisibility(
                256 //SYSTEM_UI_FLAG_LAYOUT_STABLE
                | 512 //SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | 1024 //SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | 2 //SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                | 4 //SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                | 4096 //SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );
    }

And in my manifest i have this at Application level:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

It works fine, but i have a Spinner in my app, and when i touch the spinner, the immersive mode disables!!! :S

How can this be solved?

Thanks

Upvotes: 3

Views: 2872

Answers (1)

Jasper de Vries
Jasper de Vries

Reputation: 20253

Same problem here.. See also https://code.google.com/p/android/issues/detail?id=68031

Closest I came to solving it is (in your Activity) adding the full screen flag, and setting full screen again when the activity gets focus after closing the spinner:

private void goFullScreen()
{
  // Only navigation will be shown when opening a spinner
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

  getWindow().getDecorView().setSystemUiVisibility(yourFlags);
}


@Override
protected void onResume()
{
  super.onResume();
  goFullScreen();
}


@Override
public void onWindowFocusChanged(boolean hasFocus)
{
  // Go full screen again when a spinner is closed
  if (hasFocus) {
    goFullScreen();
  }
}

Yes, it is a workaround.. I will have a look at extending the Spinner.

Upvotes: 1

Related Questions