本文介绍了Android的锁屏/解锁编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的一个应用程序中,我要锁定和编程解锁屏幕。请帮助!我没有任何想法如何开发这种类型的功能支持各个版本的Android操作系统。
I am working on a app in which I have to lock and unlock the screen programmatically. Kindly help ! I have no any idea how to develop this type of functionality which support each version of Android OS.
推荐答案
要解锁
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
final KeyguardManager.KeyguardLock kl = km .newKeyguardLock("MyKeyguardLock");
kl.disableKeyguard();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.ON_AFTER_RELEASE, "MyWakeLock");
wakeLock.acquire();
这篇关于Android的锁屏/解锁编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!