varghesekutty varghesekutty - 1 month ago 26
Android Question

getwindow() inside a view in service

I am trying to develop a lock screen. I am placing a view from my service that acts as a lock screen and display in front of all activities and i'm almost finished with it. But from my service, i am not able to access getwindow() propery to provide the following

View.SYSTEM_UI_FLAG_IMMERSIVE


Please help

Answer

I got it

Just add

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 
                        | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                PixelFormat.TRANSLUCENT);

and add it to the view

Comments