Programmatically switching off Android phone

后端 未结 6 1746
清歌不尽
清歌不尽 2020-11-22 13:02

Can we switch off an Android phone programmatically?

I am using following snippet but it didn\'t work for me.

KeyguardManager keyguardManager = (Keyg         


        
6条回答
  •  旧时难觅i
    2020-11-22 13:44

    A much better solution is to run:

    su -c am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN

    You can use a Process for this.

提交回复
热议问题