Skip to content

Commit 2364514

Browse files
jcariotiJoe
andauthored
fix(android): getDeviceName handle new exception beginning API>=32 (react-native-device-info#1471)
Co-authored-by: Joe <[email protected]>
1 parent 7945601 commit 2364514

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,11 @@ public double getLastUpdateTimeSync() {
687687
@ReactMethod(isBlockingSynchronousMethod = true)
688688
public String getDeviceNameSync() {
689689
try {
690-
String bluetoothName = Settings.Secure.getString(getReactApplicationContext().getContentResolver(), "bluetooth_name");
691-
if (bluetoothName != null) {
692-
return bluetoothName;
690+
if (Build.VERSION.SDK_INT <= 31) {
691+
String bluetoothName = Settings.Secure.getString(getReactApplicationContext().getContentResolver(), "bluetooth_name");
692+
if (bluetoothName != null) {
693+
return bluetoothName;
694+
}
693695
}
694696

695697
if (Build.VERSION.SDK_INT >= 25) {

0 commit comments

Comments
 (0)