Open ufoloko opened 8 months ago
Yes. I have same request
I did R&D on that and to show dialog over lock screen need to add some permissions
Need to add below permissions in AndroidManifest: "android.permission.FOREGROUND_SERVICE" "android.permission.WAKE_LOCK" "android.permission.SYSTEM_ALERT_WINDOW"
Now come to native part of the package there is one java file WindowSetup.Java and need to add following code for setFlag() method: static void setFlag(String name) { if (name.equalsIgnoreCase("flagNotFocusable") || name.equalsIgnoreCase("defaultFlag")) { flag = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; } if (name.equalsIgnoreCase("flagNotTouchable") || name.equalsIgnoreCase("clickThrough")) { flag = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } if (name.equalsIgnoreCase("flagNotTouchModal") || name.equalsIgnoreCase("focusPointer")) { flag = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; } }
I hope it will be useful for other. Thanks
if phone is looked and app is in background, if a service needs to show window, is not working.
I think you can add those flags
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
to be able to show window even when screen is looked