在Android设备密码是现有的或不或不、密码、设备、Android

2023-09-06 00:06:35 作者:你是我血液里的毒、

我想知道锁屏密码是否已经是present与否,在我的应用程序已经开始。

案例1:如果有一个屏幕锁的密码已经......我会做锁定(locknow()),使用设备管理器,并要求用户重新登录。

案例2:如果没有锁屏密码....我会问用户使用devicepolicymanager类设置密码。

不过,我无法知道,如何检查锁屏密码是否已present与否。有没有布尔返回在设备管理器API方法?......我无法对任何此类

我能知道活动的管理员是否present与否....现在,有人可以告诉我怎么知道锁屏密码是否已被present或不...

这是个secuirty东西,应用程序开发人员不准找?

有一个系统级的方法?

CAN设备策略管理器帮助我获得这些信息?

在此先感谢

解决方案

  KeyguardManager keyguardManager =(KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
如果(keyguardManager.isKeyguardSecure()){
   //这是密码保护
} 其他 {
   //这是没有密码保护
}
 

该方法的 isKeyguardSecure()的API级别引入16

I am trying to know whether a screen lock password is already present or not, when my app has started.

如何在Android设备上使用SDK进行截图

case 1: If there is a screen lock password already... I would do the locking (locknow()) using device manager and ask the user to login again.

case 2: If there is no screen lock password.... i would ask user to set a password using devicepolicymanager class.

But I was unable to know, how to check whether a screen lock password is already present or not. is there any boolean returning method in device manager api ?...i was unable any of such

I was able to know whether active admins are present or not.... now,can someone tell me how to know whether a screen lock password is already present or not ...

Is it a secuirty thing that app developers are not allowed to find?

Is there a system level approach?

can device policy manager help me to get that info?

thanks in advance

解决方案

KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( keyguardManager.isKeyguardSecure()) {
   //it is password protected
} else {
   //it is not password protected 
}

The method isKeyguardSecure() is introduced in API Level 16