当我在ListView
中显示它而未添加相同MAC的情况下尝试更新信标扫描器时,它不起作用。并且getTxPower()
方法不起作用。 txPower
的值仅为127
。
Android Studio API LEVEL MIN 26,altbeacon2.15.4库
final ScanResult scanResult = result;
new Thread(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
int count, checked = 0;
count = beaconListView.getCount();
beaconAdapter = new BeaconAdapter(beacon, getLayoutInflater());
beaconListView.setAdapter(beaconAdapter);
beaconAdapter.notifyDataSetChanged();
if (count > 0) {
for (int i = 0; i < beaconListView.getCount(); i++) {
if (beaconAdapter.getAddress(i) == scanResult.getDevice().getAddress()) {
//
beacon.set(i, new Beacon(scanResult.getDevice().getAddress(), scanResult.getRssi(), scanResult.getTxPower(), simpleDateFormat.format(new Date())));
checked = 1;
// listview Update
beaconAdapter.notifyDataSetChanged();
}
}
}
if (checked == 0) {
beacon.add(0, new Beacon(scanResult.getDevice().getAddress(), scanResult.getRssi(), scanResult.getTxPower(), simpleDateFormat.format(new Date())));
beaconAdapter.notifyDataSetChanged();
}
}
});
}
}).start();
同一MAC希望查找并更新,而不是添加到ListView
。