0

On some events, I'd like to lock the phone screen and require password (not fingerprint). That is, the fingerprint would be disabled just temporarily for one unlock. After the unlock, the user would be able to use fingerprint again. This is similar to the lockdown mode.

I have looked for a suitable API for that and I have found just two things:

a. Device administrator API. It seems to be the way to go, except that it is deprecated. b. GLOBAL_ACTION_LOCK_SCREEN – not deprecated, but it does not disable the fingerprint.

v6ak
  • 1,636
  • 2
  • 12
  • 27

1 Answers1

0

Please try this

KeyguradManager mgr = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
Intent i = mgr.createConfirmDeviceCredentialIntent("title", "description");
startActivityForResult(i, REQUEST_CODE);

you can handle the result in onActivityResult()

  protected void onActivityResult(int requestCode, int resultCode,
      Intent data) {
        if (requestCode==REQUEST_CODE) {
             if (resultCode==RESULT_OK) {
                //authenticated
                  }
                  else {
               // not authenticated
             }
          }
       }
Abhinav Chauhan
  • 1,304
  • 1
  • 7
  • 24
  • as you don't have language tag , i want to ask , do you want this in kotlin? – Abhinav Chauhan Jun 13 '20 at 04:34
  • If I understand correctly, this would just lock the current app, not the whole system. On language: I don't care, Java/Kotlin/Scala/Groovy are fine, maybe so would be Clojure... I am looking just for the right API, I can write the code myself. – v6ak Jun 13 '20 at 06:52
  • i thought you have an app and you want to authenticate user on some action for example deleting the account , changing password etc, and code above does not lock anything it just shows the screen to enter code or pattern and user need to enter the code/pattern which was registered in device via settings app – Abhinav Chauhan Jun 13 '20 at 11:28
  • No, I want an app running in background to detect some suspicious situations and turtle up the phone, so that the potential attacker would not be able to even use fingerprint. – v6ak Jun 13 '20 at 11:38