android4.2应用中如何控制解锁

来源:互联网 发布:淘宝访客数公式 编辑:程序博客网 时间:2024/04/27 15:38

本人比较懒,仅供参考没有验证!


以前在应用中都是通过keyguardLock来控制锁屏的,今天看了一下keyguardmanager类中的keyguardLock,如下:

    /**
     * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD}
     * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
     * instead; this allows you to seamlessly hide the keyguard as your application
     * moves in and out of the foreground and does not require that any special
     * permissions be requested.
     *
     * Handle returned by {@link KeyguardManager#newKeyguardLock} that allows
     * you to disable / reenable the keyguard.
     */
    public class KeyguardLock {
        private IBinder mToken = new Binder();
        private String mTag;


现在通过定义WindowManager.LayoutParams的模式就可以控制锁屏了,连权限都不要,方法越变越简单了



这就是java的魅力!