检测用户在 Android 中的锁屏密码错误 [英] Detect Lock Screen Incorrect Password by user in Android

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

问题描述

我正在构建一个安全应用程序,我需要知道用户是否提供了错误的密码.假设用户手机被模式锁定系统锁定,不幸的是用户忘记了模式密码.如果用户输入错误模式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:

  • 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天全站免登陆