4

I want my app to run in full-screen mode on devices running Android 4.4.

I have set View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION for my view and it runs in full-screen.

The problem is when I show a ProgressDialog. Then the app exits full-screen mode and the navigation buttons at the bottom are visible agin.

Is it possible for an app to remain in full-screen mode when a progress dialog is shown?

hichris123
  • 10,145
  • 15
  • 56
  • 70
  • Immersive mode gets removed as soon as the window loses focus and I'm unable to find any workaround. Were you able to find any answer to this? – Saket Jan 31 '14 at 20:07

1 Answers1

3

There's a little workaround I found on this topic: How to maintain the Immersive Mode in Dialogs? thanks to Beaver6813's answer (here is the sample code project on GitHub).

So basically, what I did to use this solution on my ProgressDialog is:

  • Add two variables to my MainActivity class:

    private ProgressDialog pDialog;    
    private Activity context;
    
  • Add the following code in my onCreate method:

    context = this;    
    getWindow().getDecorView().setSystemUiVisibility(    
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE    
        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION    
        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN    
        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar   
        | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar    
        | View.SYSTEM_UI_FLAG_IMMERSIVE);
    
  • Add the following code where I start my ProgressDialog method:

    pDialog = new ProgressDialog(context);    
    pDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, 
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);    
    pDialog.show();    
    pDialog.getWindow().getDecorView().setSystemUiVisibility(
        context.getWindow().getDecorView().getSystemUiVisibility());    
    pDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);    
    

That should do the trick!

Daniel
  • 2,355
  • 9
  • 23
  • 30
Jeremy.S
  • 189
  • 2
  • 10