I am trying to request Bluetooth permissions required for the Bluetooth discovery process. I have have been able to successfully request permission from the user, but when I check for permission, before calling startDiscovery(), it returns false for BLUETOOTH_CONNECT, even if the permissions were given by the user. Like the title says, is there a way around this?
this is the my instantiation of an activity result launcher:
val permissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted: Boolean ->
if (granted) {
textView1.text = "permission granted"
} else {
textView1.text = "not granted"
}
}
This is my code where I launch the activity result launcher with the permissions I need( I wasn't sure how to request multiple permissions at once):
permissionLauncher.launch(Manifest.permission.BLUETOOTH_CONNECT)
permissionLauncher.launch(Manifest.permission.BLUETOOTH_SCAN)
You should use ActivityCompat.requestPermissions() with an array of permissions to request permissions, it is likely that only one of your permissions is being granted.