Turning on screen programmatically

前端 未结 5 823
情话喂你
情话喂你 2020-11-29 07:23

I would like to unlock screen and switching it on to show a popup on an event trigger. I am able to unlock the screen using

newKeyguardLock = km.newKeyguardL         


        
5条回答
  •  感动是毒
    2020-11-29 08:21

    In your main activity's OnCreate() write following code:

    ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "TAG").acquire();
    

    It causes the device to wake up.

    Do not forget disableKeyguard() to unlock the device...

提交回复
热议问题