2
我正在通过可用范围内的Bluetooth devices
进行搜索。出于某种原因,每个找到的设备将被添加到ListView 两次,当它只应显示一次。蓝牙添加到ListView两次而不是一次
有没有人有任何想法我在做什么错在这里?代码如下。
当发现找到的设备
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);
}
}
然后它又添加了两次,而不是一个...我检查两种方式,但得到相同的结果.... !!! == ==我应用!=这个,但没有得到相同的结果...和感谢您的答复 – RobinHood 2011-05-30 07:10:23