DanaR: Fix NPE
This commit is contained in:
parent
75cb6d466c
commit
c383f471a7
1 changed files with 11 additions and 10 deletions
|
@ -191,11 +191,12 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
|
|
||||||
protected void getBTSocketForSelectedPump() {
|
protected void getBTSocketForSelectedPump() {
|
||||||
mDevName = sp.getString(R.string.key_danar_bt_name, "");
|
mDevName = sp.getString(R.string.key_danar_bt_name, "");
|
||||||
BluetoothAdapter bluetoothAdapter = ((BluetoothManager)context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
|
BluetoothAdapter bluetoothAdapter = ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
|
||||||
|
|
||||||
if (bluetoothAdapter != null) {
|
if (bluetoothAdapter != null) {
|
||||||
Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||||
|
|
||||||
|
if (bondedDevices != null)
|
||||||
for (BluetoothDevice device : bondedDevices) {
|
for (BluetoothDevice device : bondedDevices) {
|
||||||
if (mDevName.equals(device.getName())) {
|
if (mDevName.equals(device.getName())) {
|
||||||
mBTDevice = device;
|
mBTDevice = device;
|
||||||
|
|
Loading…
Reference in a new issue