Detect Lock Screen Incorrect Password by user in Android

后端 未结 3 1356
情话喂你
情话喂你 2020-12-08 09:02

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 f

3条回答
  •  无人及你
    2020-12-08 09:35

    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

提交回复
热议问题