So I know Android 12 has new Bluetooth permissions. In the App Info Permissions it looks like its called Nearby Devices now. I have this logic:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
viewModel.connectDevice(macAddressDropdown.selectedItem.toString())
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.BLUETOOTH_CONNECT),
1
)
}
}
}
On initial launch, this seems to work fine, it will prompt for the Nearby Device permission as it looks on the Google documentation. After this, I go into the Permissions in App Info, and I deny the Nearby Devices permission. When I debug this logic, it is saying BLUETOOTH_CONNECT is still allowed.
s = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED
a = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED
b = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) == PackageManager.PERMISSION_GRANTED
c = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) == PackageManager.PERMISSION_GRANTED
d = ContextCompat.checkSelfPermission(this, Manifest.permission_group.NEARBY_DEVICES) == PackageManager.PERMISSION_GRANTED
When I debug this, BLUETOOTH_CONNECT is the only one showing as true, the rest are false. Any ideas on why this is happening and how it can be fixed? Potentially a bug? Thanks
I encountered the same issue with
minSdkVersion 21
targetSdkVersion 30
compileSdkVersion 31
changing the target version to 31 fix it for me
minSdkVersion 21
targetSdkVersion 31
compileSdkVersion 31