简体   繁体   中英

Android Bluetooth permission not displayed, still descirbed as turned on

I have a problem with bluetooth permission. I've declared in the manifest following lines:

<permission android:name="android.permission.BLUETOOTH" android:label="BLUETOOTH" />
<permission android:name="android.permission.BLUETOOTH_ADMIN" />

What is weird that in app settings instead of bluetooth I've got a right to add permission for Location and Storage. But ok, lets say android doesn't provide specific perms for bluetooth and these are the same as BT. Weird thing is that even when I don't give any permission to the app (not for memory, not for localization), by using following code:

  int permissionCheck = ContextCompat.checkSelfPermission(this,
                Manifest.permission.BLUETOOTH_ADMIN);

        if(permissionCheck ==  PackageManager.PERMISSION_GRANTED){
            Toast.makeText(this, "granted", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "not granted :(", Toast.LENGTH_SHORT).show();
        }

I still get message that permission are granted. What the heck? Should I check specifically for a EXTERNAL_STORAGE and Location permissions? And why bluetooth isn't displayed in app permision configurations?

There are two types of permissions in Android:

Dangerous permissions: These permissions are required to ask on run time if targetSdkVersion is 23 or above.

Normal Permissions: If you define these permissions in Manifest that is enough.

For more details check this link given below:

https://developer.android.com/guide/topics/permissions/requesting.html#normal-dangerous

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM