Bluetooth bluetooth permissions on Android 6.0.1

1

I'm trying to get bluetooth permissions on Android 6.0 but I can not get it to work, I'm using the code of this link

   if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.BLUETOOTH_ADMIN)
            != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.BLUETOOTH_ADMIN)) {

            // Show an expanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

        } else {

            // No explanation needed, we can request the permission.

            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.BLUETOOTH_ADMIN},
                    MY_PERMISSIONS);

            // MY_PERMISSIONS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    }

Additional information:

  • Minimum version for my app: 4.0 * Added the permissions in the manifest.
asked by JeFNDZ 20.07.2018 в 16:55
source

1 answer

0

Actually the permission:

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

It is not considered a "dangerous" permission for that reason you do not need to make the request, even if you use a device with Android 6.0 or later. It is for this reason that when making the manual request it is not called.

The only thing you need for permission BLUETOOTH_ADMIN is your declaration within the file AndroidManifest.xml .

  

BLUETOOTH_ADMIN added in API level 1     public static final String    BLUETOOTH_ADMIN Allows applications to discover and link bluetooth devices ..

     

Protection level: normal

     

Constant Value: "android.permission.BLUETOOTH_ADMIN"

    
answered by 20.07.2018 в 18:41