mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
AndroidGCS: Change Sambas to not crash in AVD for bluetooth or if there are no
devices.
This commit is contained in:
parent
dd0a5b2cf2
commit
41a46258be
@ -39,15 +39,22 @@ public class BluetoothDevicePreference extends ListPreference {
|
||||
super(context, attrs);
|
||||
|
||||
BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bta == null)
|
||||
return; // BT not supported
|
||||
Set<BluetoothDevice> pairedDevices = bta.getBondedDevices();
|
||||
CharSequence[] entries = new CharSequence[pairedDevices.size()];
|
||||
CharSequence[] entryValues = new CharSequence[pairedDevices.size()];
|
||||
if (pairedDevices.size() == 0) {
|
||||
entries[0] = "No Devices";
|
||||
entryValues[0] = "";
|
||||
} else {
|
||||
int i = 0;
|
||||
for (BluetoothDevice dev : pairedDevices) {
|
||||
entries[i] = dev.getName();
|
||||
entryValues[i] = dev.getAddress();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
setEntries(entries);
|
||||
setEntryValues(entryValues);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user