安卓4.3:我如何检查是否用户已锁定启用? [英] Android 4.3 : How can I check if user has lock enabled?

查看:296
本文介绍了安卓4.3:我如何检查是否用户已锁定启用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序不同的行为(而不是存储的东西),如果用户没有锁屏或只刷卡启用。 顶部的答案在这里:检查是否启用锁或不已编辑要说code不再升级后的作品到Android 4.3。

I want my app to behave differently (not store stuff) if the user does not have a lock screen or only swipe enabled. The top answer here: check whether lock was enabled or not has been edited to say the code no longer works after upgrade to Android 4.3.

反正有检测这个在Android 4.3?

Is there anyway to detect this on Android 4.3?

推荐答案

好了,现在看来,这是可能的一些反思。不是最好的解决办法,但至少它的工作原理上我们尝试了设备:

Ok, so it seems it is possible with some reflection. Not the best solution, but at least it works on the devices we tried:

        Class<?> clazz = Class.forName("com.android.internal.widget.LockPatternUtils");
        Constructor<?> constructor = clazz.getConstructor(Context.class);
        constructor.setAccessible(true);
        Object utils = constructor.newInstance(context);
        Method method = clazz.getMethod("isSecure");
        return (Boolean)method.invoke(utils);

这篇关于安卓4.3:我如何检查是否用户已锁定启用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆