[android] check if REQUEST_BLUETOOTH_DISCOVERABLE is available before launching

This commit is contained in:
Torsten Grote
2019-11-05 12:54:02 -03:00
parent 383367f0c8
commit 5e85566fc3

View File

@@ -183,10 +183,14 @@ public abstract class KeyAgreementActivity extends BriarActivity implements
if (bt == null) {
setBluetoothState(BluetoothState.NO_ADAPTER);
} else {
setBluetoothState(BluetoothState.WAITING);
wasAdapterEnabled = bt.isEnabled();
Intent i = new Intent(ACTION_REQUEST_DISCOVERABLE);
startActivityForResult(i, REQUEST_BLUETOOTH_DISCOVERABLE);
if (i.resolveActivity(getPackageManager()) != null) {
setBluetoothState(BluetoothState.WAITING);
wasAdapterEnabled = bt.isEnabled();
startActivityForResult(i, REQUEST_BLUETOOTH_DISCOVERABLE);
} else {
setBluetoothState(BluetoothState.NO_ADAPTER);
}
}
}