Attempting to put Android device to sleep, but the PowerManager does not contain a "goToSleep(long) method

前端 未结 2 613
迷失自我
迷失自我 2020-12-21 00:59

I am attempting to put a device to sleep and I have found references all over about using the PowerManager class\'s goToSleep(long) method but I do not see it in the documen

相关标签:
2条回答
  • 2020-12-21 01:20
    PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = manager
        .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "YOUR_OWN_TAG");
    wl.acquire();
    wl.release();
    

    Try this way and give some feedback.

    0 讨论(0)
  • 2020-12-21 01:33

    You can use the DeviceAdministrator , but you need the user to grant you those rights.

    0 讨论(0)
提交回复
热议问题