How to Overlay screen?
- it should be touchable
- view must overlay system action bar
- view must overlay soft buttons back/home/recent_apps
Android 4.0 +
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); } ... }
and layout params creator
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);
}
ok, looks good.
Flag TYPE_SYSTEM_ALERT not overlays the system bar (android < 5.0), not overlays soft buttons, but I can to handle onTouch event
Flag TYPE_SYSTEM_OVERLAY overlays the system bars, not overlays buttons and I can't to handle onTouch event.
Any ideas?