Witam !
Na początku mówię że jestem początkujący w pisaniu aplikacji a chce napisać apkę do sterowania arduino, ale do rzeczy.
Czy jest jakaś osoba która jest mi w stanie wytłumaczyć czemu na liście pojawiają się zdublowane znalezione urządzenia, co robię źle ?
private final BroadcastReceiver receiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)) {
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if(bluetoothDevice.getBondState() == 10 && bluetoothDevice.getName() != "null") {
Device device = new Device(bluetoothDevice.getName(), bluetoothDevice.getAddress());
dev.add(bluetoothDevice.getName().toString());
deviceList.add(device);
}
String btname = bluetoothDevice.getName();
if(String.valueOf(btname) != bluetoothDevice.getName()) {
DeviceAdapter deviceAdapter = new DeviceAdapter(getApplicationContext(), deviceList, "bluetooth_bond_none");
listView.setAdapter(deviceAdapter);
}
}
}
};
Urządzenia się pojawiają ale są zdublowane np.
Jakis bluetooth
Jakis bluetooth
Jakis bluetooth
itp