Is there any way of waking screen pragmatically via service?

89 views Asked by At

I want mobiles screen to blink or wake once for some milliseconds. I read few questions over stackoverflow. Most of the solutions are provided to support activity. Because it needs window object which obviously belong to activity not service.

My service is foreground service, activities may get collected by system for memory. But there are very less chances of my service getting collected by system as it is foreground service.

From activity using window object by making use of following flags we can wake screen :

 WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
 WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
 WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
 WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
 WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON

Is there any other way I can wake screen from service ?

1

There are 1 answers

0
Fabian On

Maybe the answer at this question can help you.
are there anybody know how to getWindow() in service on android?

Normally I would use a comment but i canĀ“t until i have 50 reputitions.