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

前端 未结 2 617
迷失自我
迷失自我 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.

提交回复
热议问题