title: Android: system overlay
body: <p>How to Overlay screen?</p>
  
  <ol>
  <li>it should be touchable</li>
  <li>view must overlay system action bar</li>
  <li>view must overlay soft buttons back/home/recent_apps</li>
  <li><p>Android 4.0 + </p>
  
  <pre><code>public class MyService extends Service {
  
  @Override
  public void onCreate() {
      super.onCreate();
      WindowManager.LayoutParams params = ViewUtils.generateFullScreenParams(true);
  
      final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
      wm.addView(overlayView, params);
  }
  ...
  }
  </code></pre></li>
  </ol>
  
  <p>and layout params creator</p>
  
  <pre><code>public static WindowManager.LayoutParams generateFullScreenParams() {
      return new WindowManager.LayoutParams(
              WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT,
              WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
  
              WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                      | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                      | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                      | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                      | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
  
              PixelFormat.TRANSLUCENT);
  }
  </code></pre>
  
  <p>ok, looks good.</p>
  
  <p>Flag TYPE_SYSTEM_ALERT <strong>not</strong> overlays the system bar (android &lt; 5.0), <strong>not</strong> overlays soft buttons, but <strong>I can</strong> to handle onTouch event</p>
  
  <p>Flag TYPE_SYSTEM_OVERLAY <strong>overlays</strong> the system bars, <strong>not overlays</strong> buttons and I <strong>can't</strong> to handle onTouch event.</p>
  
  <p>Any ideas?</p>