title: Android/Unity - Fullscreen mode, Android's status bar, and 3D aspect ratios
body: <p>I have been racking my brain a week now trying things left and right and I cannot seem to find the answer. I might actually have more questions.</p>
  
  <p>We have an application that uses a Unity view in one of its activities to present some graphics. As this is a normal app and not a game we want to remove immersive mode and fullscreen so we can get back the system bars (status and navigation)</p>
  
  <p>Now since recent versions of Unity they added the <code>Start in fullscreen mode</code> option in the player settings for Android. The problem is that the above option brings back only the navigation bar.</p>
  
  <p>The next step was to try and bring back with some native Android coding. So basically this:
  <code>this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);</code>
  does the work and brings back the status bar.</p>
  
  <p>Now that worked like a charm until I went to a tall aspect ratio (18.5:9 - Pixel 3 XL - Android 9) device.</p>
  
  <p>If I go about it simply with the Unity fullscreen option the graphics scale nicely but I have no status bar, something that is even more apparent to notched phone:</p>
  
  <p><a href="https://i.stack.imgur.com/8jAkb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8jAkb.png" alt="enter image description here"></a></p>
  
  <p>If I remove the fullscreen flag from Android then I get my status bar back but the rendering breaks:</p>
  
  <p><a href="https://i.stack.imgur.com/GF2BZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GF2BZ.png" alt="enter image description here"></a></p>
  
  <p>The <code>???</code> is the black area that appears. </p>
  
  <p>Sorry, I cannot show you the actual app.</p>
  
  <p>Now, I played around with other flags of the so called "immersive mode":</p>
  
  <pre><code>// When init of Unity
  this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  this.showSystemUi();
  this.addUiVisibilityChangeListener();
  
  // What the above does
  private static int getLowProfileFlag() {
      return Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT ? View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
              View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
              View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
              View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
              View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
              View.SYSTEM_UI_FLAG_FULLSCREEN : View.SYSTEM_UI_FLAG_LOW_PROFILE;
  }
  
  private void showSystemUi() {
      this.mUnityPlayer.setSystemUiVisibility(this.mUnityPlayer.getSystemUiVisibility() &amp; ~getLowProfileFlag());
  }
  
  private void addUiVisibilityChangeListener() {
      this.mUnityPlayer.setOnSystemUiVisibilityChangeListener(visibility -&gt; RadarOverviewActivity.this.showSystemUi());
  }
  </code></pre>
  
  <p>and under circumstances a similarly sized black bar appears above the graphics area.</p>
  
  <p>Finally when the black bars are there the native UI also breaks. For the bottom bar there should be some tooling there that gets pushed up where the graphics actually start. The bottom black bar is part of UnityPlayer as touching there can actually cause interaction with the graphics. The top bar, when it is there, is even weirder. That area is actually where the native toolbar should be and in a way is. It cannot be seen but touching there triggers the UI events!!! It looks like the Unity view cannot place itself properly when not in fullscreen, as the Native UI initially appears correctly but when Unity kicks in goes all weird. To point the attention once more. This happens only in tall aspect devices. 16:9 devices seem to have no issues.</p>
  
  <p>So the main question is, How do I take the app out of Fullscreen, with the status bar appearing and not breaking the Unity rendering in tall aspects?</p>