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.