範囲内で利用可能なものを検索していますBluetooth devices
。何らかの理由で、見つかった各デバイスは2回ListViewに追加されますが、 1回だけ表示する必要があります。
誰かが私がここで間違っていることを知っていますか?以下に含まれるコード。
ディスカバリーがデバイスを見つけたとき
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device;
device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() == BluetoothDevice.BOND_BONDED) {
Log.v("test", "test");
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
// When discovery is finished, change the Activity title
setProgressBarIndeterminateVisibility(false);
setTitle(R.string.select_device);
if (mNewDevicesArrayAdapter.getCount() == 0) {
String noDevices = getResources().getText(R.string.none_found).toString();
mNewDevicesArrayAdapter.add(noDevices);
}
}