Android - Activation of the system key lock (aka lock screen)

前端 未结 5 2150
借酒劲吻你
借酒劲吻你 2020-12-31 12:33

I have to activate android\'s system key lock (the one you get when you press the power off/hang up button). See here:

5条回答
  •  忘掉有多难
    2020-12-31 12:57

    Looks like the screen lock function is performed using the method:

    public void goToSleep(long time)
    

    method in PowerManager.java. It's possible to get a reference to it in this fashion:

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    

    However this requires the permission

    android.permission.DEVICE_POWER
    

    which is a level 2 permission available to the system only.

    So looks like this isn't doable. This is for version 1.1 only, I don't know for 1.5.

提交回复
热议问题