Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Lock Screen Incorrect Password by user in Android

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,

like image 647
user2166895 Avatar asked Apr 05 '14 11:04

user2166895


People also ask

How can I tell if someone is trying to unlock my phone?

LockwatchLockwatch is a great overall app for taking pictures of people trying to unlock your phone. It's a straightforward solution that's easy to use: just enable it and you'll get an email when someone tries to break into your phone. To start using Lockwatch, open the app and enable the Send alert email slider.

How can I guess my lock screen password?

To find this feature, first enter an incorrect pattern or PIN five times at the lock screen. You'll see a “Forgot pattern,” “forgot PIN,” or “forgot password” button appear. Tap it. You'll be prompted to enter the username and password of the Google account associated with your Android device.

How do you get your phone to take a picture when the wrong password is entered?

HiddenEye – This Android app takes a picture when someone tries to unlock your phone by incorrectly guessing your passcode. The app can also be synced with your Dropbox account, so any pictures taken can be sent there directly.

How do I unlock my Android if I forgot my lock screen password?

If you've failed to unlock your phone 5 times, you'll have a message pop up. At the bottom right of your screen, you'll see a “Forgot Pattern?” button. Tap it. You can then enter your Google account details and Google will send you through an e-mail with your new unlock code.


2 Answers

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
like image 195
CommonsWare Avatar answered Oct 02 '22 22:10

CommonsWare


I am doing the same thing on android studio with API level-22. but nothing is happening . Its showing an error- "Installing com.example.sourav.myfirstapp DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.sourav.myfirstapp" pkg: /data/local/tmp/com.example.sourav.myfirstapp Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]"

Here is my detail of my project - Admin receiver main activity-

public class AdminReceiver extends DeviceAdminReceiver {

@Override
public void onPasswordChanged(Context ctxt, Intent intent) {
    DevicePolicyManager mgr=
            (DevicePolicyManager)ctxt.getSystemService(Context.DEVICE_POLICY_SERVICE);
    int msgId;

    if (mgr.isActivePasswordSufficient()) {
        msgId=R.string.compliant;
    }
    else msgId = R.string.not_compliant;

    Toast.makeText(ctxt, msgId, Toast.LENGTH_LONG).show();
}

@Override
public void onPasswordFailed(Context ctxt, Intent intent) {
    Toast.makeText(ctxt, "u will never break!", Toast.LENGTH_LONG)
            .show();
    String tag="tag";
    Log.v(tag,"this massage from error" );
}

@Override
public void onPasswordSucceeded(Context ctxt, Intent intent) {
    Toast.makeText(ctxt, "good u enterd", Toast.LENGTH_LONG)
            .show();
    String tag="tag";
    Log.v(tag, "this massage from success");
}
}

manifest-

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.sourav.myfirstapp" >
 


 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >

    <receiver
        android:name="AdminReceiver"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data
            android:name="android.app.device_admin"
            />

        <intent-filter>

            <action    android:name="android.app.action.ACTION_PASSWORD_FAILED"/>
            <action     android:name="android.app.action.ACTION_PASSWORD_SUCCEEDED"/>
        </intent-filter>
    </receiver>
</application>

 </manifest>




Metadata-
 
 <device-admin xmlns:android="http://schemas.android.com/apk/res/android">

   <uses-policies>
    <limit-password/>

    <watch-login/>
</uses-policies>
like image 41
guddu kumar sharma Avatar answered Oct 02 '22 22:10

guddu kumar sharma