X-SLAYER / flutter_overlay_window

Flutter plugin for displaying flutter app over other apps on the screen
https://pub.dev/packages/flutter_overlay_window
MIT License
110 stars 117 forks source link

Please add more flags to show when phone is looked #98

Open ufoloko opened 8 months ago

ufoloko commented 8 months ago

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

nambui2000k commented 8 months ago

Yes. I have same request

Ridham-Vaghani commented 7 months ago

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