26

How to launch finger print enrollment settings screen(Add fingerprint screen) from my app?

After enrolling finger print, is there any way to navigate back to my application? (with startActivityForResult)

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Ponsuyambu
  • 7,876
  • 5
  • 27
  • 41

6 Answers6

21

After reading the docs, I found out that as of now, there is no such intent action available. I launched the security settings(where fingerprints option available) with the below Intent.

startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS));
Ponsuyambu
  • 7,876
  • 5
  • 27
  • 41
21

with API >= P there is Settings.ACTION_FINGERPRINT_ENROLL & BiometricPrompt.

@RequiresApi(api = Build.VERSION_CODES.P)
private void startFingerprintEnrollment(@NonNull AppCompatActivity activity) {
    Intent intent = new Intent(Settings.ACTION_FINGERPRINT_ENROLL);
    activity.startActivityForResult(intent, REQUESTCODE_FINGERPRINT_ENROLLMENT);
}

compared to API >= M:

@SuppressWarnings("deprecation")
@RequiresApi(api = Build.VERSION_CODES.M)
private void gotoSecuritySettings(@NonNull AppCompatActivity activity) {
    Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
    activity.startActivityForResult(intent, REQUESTCODE_SECURITY_SETTINGS);
}

think this is the FingerprintEnrollIntroduction ...

onboarding activity for fingerprint enrollment.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • 1
    how do you handle `Settings.ACTION_FINGERPRINT_ENROLL)` resultCode? As I was checking the AOSP source code, it returns `Activity.RESULT_FIRST_USER` instead of classical `Activity.RESULT_OK` – mlykotom Sep 02 '19 at 10:10
  • link broken in answer above – Jeeva Mar 30 '20 at 04:49
  • The link does a) not matter much and b) might be temporarily down. Just search by filename and you might eventually find another mirror. – Martin Zeitler Mar 30 '20 at 04:59
11

Suggested answer lack of an important point: if the user need to enroll a BIOMETRIC_STRONG type of biometry an Extra need to be added to the intent in order to correctly open BiometricEnrollActivity.

If I try to enroll a STRONG biometry with a WEAK biometry already enrolled the startActvity command fails to open the activity.

So the complete snippet used to bring the user to enroll a BIOMETRIC_STRONG is:

val intent: Intent = when {
  Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> {
     Intent(Settings.ACTION_BIOMETRIC_ENROLL).putExtra(EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, BiometricManager.Authenticators.BIOMETRIC_STRONG)
  }
   Build.VERSION.SDK_INT >= Build.VERSION_CODES.P -> {
     Intent(Settings.ACTION_FINGERPRINT_ENROLL)
   }
   else -> {
     Intent(Settings.ACTION_SECURITY_SETTINGS)
   }
}

if(intent.resolveActivity(context!!.packageManager) != null){
   startActivity(intent)
  }else{
   startActivity(Intent(Settings.ACTION_SETTINGS))
}
Jai Khambhayta
  • 4,198
  • 2
  • 22
  • 29
GareDeveloper
  • 393
  • 1
  • 3
  • 13
6

Suggested answer won't work for example on Huawei P9. Fingerprint settings on this model is available from: startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));.

Another thing is that when you launch system settings on your app task, enroll new fingerprint and return by back press you won't be able to encrypt any message on first authorization. The best thing is if user set app to background and enroll finger on his own, then restore app, encrypting will work. I have no idea what is the reason of such behaviour, so I suggest to just inform user about posibility of enroll finger.

Karol Kulbaka
  • 1,136
  • 11
  • 21
2

Solution: If your target API level is 30 and above

Settings.ACTION_FINGERPRINT_ENROLL was deprecated in API level 30 see

Use this:

startActivity(Intent(Settings.ACTION_BIOMETRIC_ENROLL))

But may this will not support in all android devices due to custom os,

I suggeset use like this:

try {
       startActivity(Intent(Settings.ACTION_BIOMETRIC_ENROLL))
} catch (e: Exception) {
       startActivity(Intent(Settings.ACTION_SETTINGS))
}
Deven
  • 3,078
  • 1
  • 32
  • 34
0
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
    startActivity(new Intent(Settings.ACTION_BIOMETRIC_ENROLL));
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
    startActivity(new Intent(Settings.ACTION_FINGERPRINT_ENROLL));
} else {
    startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
}
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 10 '21 at 23:13