Android: How to turn screen on and off programmatically?

后端 未结 16 2391
醉酒成梦
醉酒成梦 2020-11-22 13:05

Before marking this post as a \"duplicate\", I am writing this post because no other post holds the solution to the problem.

I am trying to turn off the device, then

16条回答
  •  臣服心动
    2020-11-22 13:36

         WakeLock screenLock =    ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(
        PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
        screenLock.acquire();
    
      //later
      screenLock.release();
    

    //User Manifest file

提交回复
热议问题