I'm doing this app were I get the RSSI measurements from previous choosen APs (whch are retrieved in the "recebidos" variable stated in the code bellow!), but after the scan in broadcast receive the application is not updating the RSSI value, it is just returning the previous value all the time!!!
What is wrong in this code, can't I use getScanResults with the WifiManager.SCAN_RESULTS_AVAILABLE_开发者_StackOverflowACTION
?
Please help me...
private final BroadcastReceiver wifiReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context ctx, Intent intent)
{
listaAP=wifiManager.getScanResults();
recebidos=nivel.split("SP1");
StringBuffer scanList = new StringBuffer();
if (listaAP != null) {
for (int i = listaAP.size() - 1; i >= 0; i--) {
final ScanResult scanResult = listaAP.get(i);
if (scanResult == null) {
continue;
}
if (TextUtils.isEmpty(scanResult.BSSID)) {
continue;
}
scanList.append("SP1ID:"+scanResult.BSSID+"RSSI"+scanResult.level);
}
results=scanList.toString().split("SP1");
for(int z=0;z<results.length;z++)
{
for(int x=0;x<recebidos.length;x++)
{
if(results[z].compareTo(recebidos[x])==0)
{
textRssi.append(results[z]);
}
}
}
}}};
You should call android.net.wifi.WifiManager.startScan() or startScanActive() to force another scan - it won't update the data unless you'll call this periodically.
精彩评论