0

I have search a lot but my query not match to it, i found the solution for lock and unlock the phone

Like this way I have created my broadcast with the 3 filters which I recieved:

public class ScreenReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
            Log.e(TAG, "In Method:  ACTION_SCREEN_OFF");
        } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
            Log.e(TAG, "In Method:  ACTION_SCREEN_ON");
        } else if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
            Log.e(TAG, "In Method:  ACTION_USER_PRESENT");
        }
    }
}

I need to find out the way user is unlock screen with it type. if user has unlocked screen by using the password or pattern or fingerprint or by button.

So I am not able to get the particular event from which I can get the follow output.

So kindle help to go in the right direction.

Siddharth Patel
  • 205
  • 1
  • 13

1 Answers1

0

To detect lock pattern I have used below code.So, I think it also help you.you can use Settings.Secure.LOCK_PATTERN_ENABLED flag. Show below:-

private static boolean CheckPatternSet(Context context)
{
    ContentResolver contentResolver = context.getContentResolver();
    try
    {
        int lockEnabled = Settings.Secure.getInt(contentResolver, Settings.Secure.LOCK_PATTERN_ENABLED);
        return lockEnabled == 1;
    }
    catch (Settings.SettingNotFoundException e)
    {
        return false;
    }
} 

For More understanding you can show below stackoverflow link :-

Android check if lockscreen is set

Janvi Vyas
  • 732
  • 5
  • 16