title: Detect Status Bar Visibility / TYPE_SYSTEM_OVERLAY not resizing automatically
body: <p>I'm using the well known <code>TYPE_SYSTEM_OVERLAY</code> method to create a full screen overlay that's always on top of other views.</p>
  
  <p>On a <code>Moto Atrix2 API15</code> and for each <code>AVD</code> from <code>API 10</code> through <code>17</code> the overlay view resizes automatically (expands vertically) when the status bar is hidden by another app.  The overlay appears to "stay on top" of all other views, as I think it should.  When the status bar is in view again, the overlay reduces it's size automatically again (less vertical pixels, basically subtracting the height of the status bar).</p>
  
  <p>This is the desired behavior and am inclined to think this is not the exception or flawed behavior due to it working on many different emulators as well as at least one device manufacturer (<em>motorola</em>), perhaps more, but I don't have access to <code>addtl devices.</code></p>
  
  <p><strong>The problem:</strong>  On a <code>Samsung GS2 (API15)</code> &amp; also tested on <code>Kindle Fire (API10?)</code>, the overlay does not automatically resize (fill the space where the status bar once was) when the status bar is hidden by another app (status bar behind full screen app).  On these devices, after the view is created the first time I don't get any more events from an onSizeChanged override for the view.</p>
  
  <p>Here's the pertinent code:</p>
  
  <pre><code>params = new WindowManager.LayoutParams( 
      1, WindowManager.LayoutParams.MATCH_PARENT, 
      WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 
      WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
      |WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, 
      PixelFormat.TRANSPARENT);
  wm.addView(sizeLayout, params);
  </code></pre>
  
  <p>sizeLayout has the onSizeChanged override.</p>
  
  <p>I've played around with just about every <code>windowmanager</code> <code>layoutparam</code> I can find, including SYSTEM_ALERT, FLAG_LAYOUT_IN_SCREEN, etc.  I won't sleep until I can figure this out!</p>
  
  <p><strong>Edit 11/30/12</strong>: I found this from @deviant: <a href="https://stackoverflow.com/a/9195733/1851478">https://stackoverflow.com/a/9195733/1851478</a> which is basically what I'm doing, however the problem remains with certain devices not resizing the system_overlay automatically.  Perhaps I should raise a bug.</p>
  
  <p>More INFO: IF I force a redraw (or even just load the overlay app) while there is a full screen app at the top of the view tree, my overlay still does not draw over the space the status bar normally takes up (even though the status bar is not in view at the time of draw), so it seems as if the overlay is not "overlayed" on top of the frontmost window which is full screen (and I've both created and tested many full screen apps using a variety of methods to make them go full screen).  On these devices, the only way to get the overlay to draw over the status bar (even if the status bar is not in view) is to use the flag <code>FLAG_LAYOUT_IN_SCREEN</code>, but then the size of the layout never changes, is always full screen, and thus back to the original problem why this works on some devices but not others.</p>
  
  <p><strong><em>Edit 12/12/12</em></strong>:  So I haven't had any further luck on this, and I did try using getLocalVisibleRect on views, but unfortunately since my app doesn't own the SystemUI views it can't detect what's below the overlays.  I suppose with a custom ROM I could do this, but I need a solution without root.</p>
  
  <p>I do see other apps on the marketplace are having the same problem detecting the status bar on the non-working phones I listed above.  Example: cool tool, omega statusbar &amp; status bar +.  Bounty raised.</p>
  
  <p><strong><em>Edit 12/19/12</em></strong> Pictures added.  Note that on a working device the gray area also "covers" the black area (any app that is currently full screen), the black area actually covers entire screen, I'm just showing the gray area as my overlay even though it is also full screen (minus or plus the height of the status bar depending on working/non-working device and whether it is in view or not).</p>
  
  <p><img src="https://i.stack.imgur.com/JBdWb.png" alt="enter image description here">       <img src="https://i.stack.imgur.com/Bn9Zp.png" alt="enter image description here"></p>