Intent to launch fingerprint enrollment screen
Asked Answered
C

6

27

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)

Claude answered 16/9, 2016 at 8:9 Comment(0)
C
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));
Claude answered 28/10, 2016 at 16:19 Comment(0)
G
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.

Gass answered 12/11, 2018 at 22:50 Comment(3)
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_OKForefend
link broken in answer aboveLyckman
The link does a) not matter much and b) might be temporarily down. Just search by filename and you might eventually find another mirror.Gass
R
12

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))
}
Resection answered 10/2, 2022 at 15:21 Comment(2)
what if for the 2nd case we have face id also in the settingsFloatfeed
Can you explain better, what do you mean with 2nd case? Maybe SDK version < R and >= P? EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED was added only in API 30 (R)Resection
L
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.

Licorice answered 7/6, 2017 at 7:43 Comment(0)
M
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))
}
Monomorphic answered 12/5, 2021 at 6:58 Comment(0)
J
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));
}
Janettejaneva answered 10/12, 2021 at 14:42 Comment(1)
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.Brewery

© 2022 - 2024 — McMap. All rights reserved.