Do not crash on null BT adapter, allows UI work on emulator.

here
Lem Dulfo 2016-04-09 09:12:40 +08:00 committed by cpfeiffer
parent 57ecba16f3
commit 3ef942b5d3
1 changed files with 5 additions and 0 deletions

View File

@ -290,6 +290,11 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
return false;
}
BluetoothAdapter adapter = bluetoothService.getAdapter();
if (adapter == null) {
LOG.warn("No bluetooth available");
this.adapter = null;
return false;
}
if (!adapter.isEnabled()) {
LOG.warn("Bluetooth not enabled");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);