Skip to content

Commit

Permalink
fixed issue #162 for android 11
Browse files Browse the repository at this point in the history
  • Loading branch information
hpsaturn committed Mar 5, 2024
1 parent 046334a commit 5f3c4a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,10 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
break;
}
Log.i(TAG, "[PERM] User granted bluetooth connect permission");
requestBluetoothScanPermission();

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R)
requestBluetoothScanPermission();
else
requestLocationPermission();
case BLUETOOTH_SCAN:
if (grantResults.length == 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "[PERM] User denied scan nearby devices");
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/hpsaturn/pollutionreporter/PermissionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ public static String[] getBackgroundPermissions() {
}

public static String[] getBluetoothPermission() {
return new String[]{
Manifest.permission.BLUETOOTH_CONNECT,
};
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
return new String[]{
Manifest.permission.BLUETOOTH_CONNECT,
};
}
else {
return new String[]{
Manifest.permission.BLUETOOTH,
};
}
}

public static String[] getBluetoothScanPermission() {
Expand Down

0 comments on commit 5f3c4a4

Please sign in to comment.