我正在尝试每秒扫描一次接入点。这就是我在做什么。
if (isScanning()) {
new Timer().schedule(new TimerTask() {
@Override
public void run()
{
results = manager.getScanResults();
manager.startScan();
}
}, 0,1000);
adapter.notifyDataSetChanged();
我正在使用BaseAdapter显示结果。
public View getView(int position, View convertView, ViewGroup parent) {
ScanResult result = results.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.network_list_row, null);
}
// Get textview fields
TextView txtSSID = (TextView) convertView.findViewById(R.id.txtSSID);
TextView txtBSSID = (TextView) convertView.findViewById(R.id.txtBSSID);
TextView txtCapabilities = (TextView) convertView
.findViewById(R.id.txtCapabilities);
TextView txtFrecuency = (TextView) convertView
.findViewById(R.id.txtFrecuency);
TextView txtLevel = (TextView) convertView.findViewById(R.id.txtLevel);
if (result.SSID.equalsIgnoreCase(ScanNetworks.manager
.getConnectionInfo().getSSID()))
{
txtSSID.setText(convertView.getContext().getString(
R.string.ssid_msg, result.SSID));
txtBSSID.setText(convertView.getContext().getString(
R.string.bssid_msg, result.BSSID));
txtCapabilities.setText(convertView.getContext().getString(
R.string.capabilities_msg, result.capabilities));
txtFrecuency.setText(convertView.getContext().getString(
R.string.frecuency_msg,
Integer.toString(result.frequency)));
txtLevel.setText(convertView.getContext().getString(
R.string.signal_level_msg,
Integer.toString(result.level)));
;
当我显示扫描结果时,我看到很多重复项。我知道调用startScan()的每一秒都有重叠。有没有办法可以消除显示屏中的重复项?另外,如何同步startScan()和getScanresults()调用? 请指教。 感谢