title: How do I hide the navigation bar despite having window popups, overlays or dialogs that appear?
body: <p>I am trying to create a fullscreen app that launches at specific times, and when it launches, it should automatically become full screen. I have no problems launching it with full screen. However, if there are popups or windows that exist, and then my activity gets launched, the navbar never gets hidden (in other words, full screen state is not achieved). I have created a 5 second video to demonstrate this problem. </p>
  
  <p>You can view the bug here: <a href="http://tinypic.com/player.php?v=2qkplwp%3E&amp;s=9#.V3fZ8KLA3Fk" rel="nofollow">http://tinypic.com/player.php?v=2qkplwp%3E&amp;s=9#.V3fZ8KLA3Fk</a></p>
  
  <p>I've tried everything with flags, but can't seem to get it done. I have looked around the Playstore and it seems many lockscreen apps especially can easily hide the navbar despite any popups\other dialogs existing (SlideLock, Echo Lock Screen). </p>
  
  <p>Below is my simple activity code:</p>
  
  <p>In manifest: <code>&lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /&gt;</code></p>
  
  <p><strong>windowlayout.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#a9e487"&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Exit"
      android:id="@+id/button"
      android:layout_gravity="center"
      android:layout_marginTop="100dp" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      final static WindowManager.LayoutParams params = new WindowManager.LayoutParams(
              WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
              WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
              WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS |
              WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION |
              WindowManager.LayoutParams.FLAG_FULLSCREEN |
              WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
              WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, //Covers status bar
              PixelFormat.TRANSPARENT);
  
      final static int flags = 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
              | View.SYSTEM_UI_FLAG_FULLSCREEN
              | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.content_main);
  
          final View decorView = getWindow().getDecorView();
          decorView.setSystemUiVisibility(flags);
  
          final ViewGroup viewGroup = (ViewGroup) getLayoutInflater().inflate(R.layout.windowlayout, null);
          final WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
          windowManager.addView(viewGroup, params);
  
          viewGroup.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  windowManager.removeView(viewGroup);
              }
          });
  
      }
  
  }
  </code></pre>