Fixed crash if no bluetooth adapter available to get device name
This commit is contained in:
parent
0525386363
commit
076ceff33e
2 changed files with 10 additions and 2 deletions
|
@ -48,7 +48,10 @@ class ApiTwentySixPlus {
|
|||
Settings.Global.getString(
|
||||
context.getContentResolver(), Settings.Global.DEVICE_NAME);
|
||||
if (name == null) {
|
||||
name = BluetoothAdapter.getDefaultAdapter().getName();
|
||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (adapter != null) {
|
||||
name = adapter.getName();
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
name = Settings.Secure.getString(context.getContentResolver(), "bluetooth_name");
|
||||
|
|
|
@ -51,7 +51,12 @@ public class Compatibility {
|
|||
return ApiTwentySixPlus.getDeviceName(context);
|
||||
}
|
||||
|
||||
String name = BluetoothAdapter.getDefaultAdapter().getName();
|
||||
String name = null;
|
||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (adapter != null) {
|
||||
name = adapter.getName();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = Settings.Secure.getString(context.getContentResolver(), "bluetooth_name");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue