Can I shut down my Android phone on the program?
Second question: How do we programatically lock and unlock Android screens?
I tried the following code, but it didn't work.
KeyguardManager keyguardManager =
(KeyguardManager) getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard(); // disable code
lock.greenableKeygard();// enable code
And I also wrote a permission.
android
If you need a reboot, you can use PowerManager (the reboot is not guaranteed because the OS may reject it)
http://developer.android.com/reference/android/os/PowerManager.html#reboot(java.lang.String)
REBOOT permission is required.
http://developer.android.com/reference/android/Manifest.permission.html#REBOOT
And check the logcat that occurs when you try enable/disable keyguard. Could you put it up here, if possible?
© 2024 OneMinuteCode. All rights reserved.