Skip to content Skip to sidebar Skip to footer

How To Know If Users Entered A Wrong Passcode (lock Screen) In Android App

I am working on an Android App in which one of the activity has to be completed if user enter a wrong passcode in android lock screen. For example an email sent if user entered a w

Solution 1:

The lock screen are running in a total sandbox environment which makes it makes it inaccessible.You can create a different Application acting as the lock screen and disabling the default android version.

Solution 2:

You can do this by registering your app as Device Administrator. Add watch-login tag to device admin metadata and then you will be able to handle onPasswordFailed and onPasswordSucceeded events. create a file named device_admin.xml in your res/xml folder and put these tags inside it:

<?xml version="1.0" encoding="utf-8"?><device-adminxmlns:android="http://schemas.android.com/apk/res/android"><uses-policies><watch-login /></uses-policies></device-admin>

then you need to create a AdminReciever class that extends from DeviceAdminReceiver. inside this class you can handle onPasswordFailed and do what you need if user entered incorrect password. you can see full example here: Password Enforcer SampleNOTE as far as i know, this works only with Password and PIN and Patterns is not supported.

Post a Comment for "How To Know If Users Entered A Wrong Passcode (lock Screen) In Android App"