How to turn screen off or send device to sleep

后端 未结 2 1352
无人共我
无人共我 2020-12-31 08:57

I want to send device to sleep or turn the screen off. I have investigated and found this topic: Turn off screen on Android

Basically, the are three ways to do it, b

2条回答
  •  情话喂你
    2020-12-31 09:33

    I answer myself. It is possible to turn off the device, but the application has to implement the device administrator feature via API: Device Administration

    In this API there is a locknow() function that do what I want.

    Anyway, this is for extending the android hardware and security features and it is very unlikely that anyone wants to control the device in that way.

    What I wanted is the ability to lock the device from a simple gesture. As I dont want to make my own device manager class I check if the free application "lockScreen" is installed and launch it. It is a shortcut and an easy way to do what I want. This app must be register as device manager so it has implemented this class. It is possible to get it free from the market.

提交回复
热议问题