检测锁屏密码不正确用户在Android中 [英] Detect Lock Screen Incorrect Password by user in Android

查看:209
本文介绍了检测锁屏密码不正确用户在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个安全的应用程序,我需要知道,如果用户正在给密码不正确。假设用户手机由图案锁系统锁定,不幸的是用户忘记了图案password.When用户给出错误的模式5的时候,会有一个点球,持续30秒。 我需要赶上处罚事件。 在我的应用程序,我不得不做一些任务(用户安全)时,这甚至来了。 请帮帮我,

I am building a security app and I need to know if the user is giving incorrect password . Suppose user phone is locked by pattern lock system , and unfortunately user has forgotten the pattern password.When user give wrong pattern 5 time, there will be a penalty for 30 sec . I need to catch that penalty event . In my app, i have to do some task (for the safety of user) when this even come . Please help me,

推荐答案

您可以设置 DeviceAdminReceiver 将被通知失败的密码尝试,以及作为一个成功的密码尝试失败的尝试之后发生的。这会在 Android的设备管理API的文档

You can set up a DeviceAdminReceiver that will be notified about failed password attempts, as well as a successful password attempt that occurred after a failed attempt. This is covered in the documentation of Android's device administration APIs.

请注意,用户必须同意让您的应用程序作为一个设备管理员,通过设置应用程序之前,你会得到这些事件。

Note that the user will have to agree to allow your app to serve as a device administrator, via the Settings app, before you will get these events.

此示例项目演示监听这些事件,再加上设置了密码质量政策。关键的部分是:

This sample project demonstrates listening for those events, plus setting up a password quality policy. The key pieces are:

  • <一个href="https://github.com/commonsguy/cw-omnibus/blob/master/DeviceAdmin/PasswordEnforcer/src/com/commonsware/android/pwenforce/AdminReceiver.java">the DeviceAdminReceiver 实施
  • <一个href="https://github.com/commonsguy/cw-omnibus/blob/master/DeviceAdmin/PasswordEnforcer/res/xml/device_admin.xml">the设备管理元数据,说明什么是管理能力,你的应用程序要
  • 接收器在<一款入门href="https://github.com/commonsguy/cw-omnibus/blob/master/DeviceAdmin/PasswordEnforcer/AndroidManifest.xml">the清单
  • code在<一个href="https://github.com/commonsguy/cw-omnibus/blob/master/DeviceAdmin/PasswordEnforcer/src/com/commonsware/android/pwenforce/MainActivity.java">the活动来检测,如果你的应用程序被批准作为设备管理员,如果没有,导致用户在设置现场进行改变
  • the DeviceAdminReceiver implementation
  • the device admin metadata, stating what administrative capabilities your app wants
  • the receiver's entry in the manifest
  • code in the activity to detect if your app is approved to serve as a device administrator and, if not, lead the user to the spot in Settings to make that change

这篇关于检测锁屏密码不正确用户在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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