title: Android overlay window that pauses underlying app's activity
body: <p>I have a service that creates an overlay or &quot;floating&quot; window that is displayed over other apps. I would like this window to behave more like an activity in that when it's shown, windows/apps underneath should pause. This is not happening by default.</p>
  <p>The window should be focusable already as it is receiving touch events. Is there a way to take focus away from apps underneath so as to pause them?</p>
  <p>Here is my code for the overlay window:</p>
  <pre><code>WindowManager.LayoutParams paramsOverlayView = new WindowManager.LayoutParams(realScreenSize.x, realScreenSize.y, 0, 0,
              Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
              WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, 
              PixelFormat.TRANSLUCENT);
  
  windowManager.addView(viewOverlay, paramsOverlayView);
  </code></pre>