Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android nougat USE_FINGERPRINT permissions

I'm trying to implement the fingerprint and not sure if it's an issue but on Android Nougat the permissions for the USE_FINGERPRINT is never asked. So I never get the dialog popup. I have the implementation for ACCESS_FINE_LOCATION and it works (the app ask to allow or deny).

In my manifest:

<uses-permission android:name="android.permission.USE_FINGERPRINT" />

<uses-feature
    android:name="android.hardware.fingerprint"
    android:required="false" />

In the fragment

if (ActivityCompat.checkSelfPermission(getActivity(),Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
        Log.v(TAG, "NO permissions USE_FINGERPRINT");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            Log.v(TAG, "No requestPermissions");
            ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.USE_FINGERPRINT}, FingerprintHandler.FINGERPRINT_PERMISSION);
        }
        return;
    }
like image 381
returnvoid Avatar asked Nov 22 '17 06:11

returnvoid


People also ask

What does Read_phone_state permission do?

READ_PHONE_STATE is one of the Android permissions categorized as dangerous. This is because it “allows read only access to phone state, including the phone number of the device, current cellular network information, the status of any ongoing calls, and a list of any Phone Accounts registered on the device” [2] .

How do I request runtime permission on Android?

checkSelfPermission(String perm); It returns an integer value of PERMISSION_GRANTED or PERMISSION_DENIED. Note: If a user declines a permission that is critical in the app, then shouldShowRequestPermissionRationale(String permission); is used to describe the user the need for the permission.

What is Android permission Get_accounts?

android.permission.GET_ACCOUNTS. Allows access to the list of accounts in the Accounts Service. The app uses this permission in an effort to find the device user's name when the support session is presented to a representative.


3 Answers

This is normal. The Fingerprint permission is not marked as dangerous and thus you don't have to ask for access to it. It is granted automatically if you declare the permission in your manifest.

This is because you cannot access the sensor directly and all calls to it are proxied trough the FingerprintManager which is somewhat limited.

Edited March 2019: USE_FINGERPRINT is deprecated in favor of USE_BIOMETRIC, but can still be used. USE_BIOMETRIC is granted by declaring it in the manifest as well.

like image 100
Ch4t4r Avatar answered Oct 12 '22 02:10

Ch4t4r


It wont ask you to grant permission because of its level of protection (Normal, not dangerous). So access will be automatically granted just by requesting it and without knowledge of the user.

like image 3
Juan Carlos Iturriagagoitia Avatar answered Oct 12 '22 02:10

Juan Carlos Iturriagagoitia


follow this steps:

Add this in manifest above permission:

 <uses-feature android:name="android.hardware.fingerprint" android:required="true" />

you always need permission to access any hardware resources of phone. So it will do that for you.

Then in activity , do following code:

   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);

        if (!fingerprintManager.isHardwareDetected()) {
            Toast.makeText(getApplicationContext(), "Your device doesn't support fingerprint authentication", Toast.LENGTH_SHORT).show();
        }
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
            Toast.makeText(getApplicationContext(), "Please enable the fingerprint permission", Toast.LENGTH_SHORT).show();

        ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.USE_FINGERPRINT}, FingerprintHandler.FINGERPRINT_PERMISSION);

        }

        if (!fingerprintManager.hasEnrolledFingerprints()) {
            Toast.makeText(getApplicationContext(), "Your Device has no registered Fingerprints! Please register atleast one in your Device settings", Toast.LENGTH_LONG).show();
        }
}

I think it work for you. Thanks!!

like image 1
Ankit Patidar Avatar answered Oct 12 '22 02:10

Ankit Patidar