1
0
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:
James Cotton 2012-08-08 13:42:27 -05:00
parent dd0a5b2cf2
commit 41a46258be

View File

@ -39,14 +39,21 @@ 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()];
int i = 0;
for (BluetoothDevice dev : pairedDevices) {
entries[i] = dev.getName();
entryValues[i] = dev.getAddress();
i++;
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);