Using WifiManager.startScan()

1k Views Asked by At

after WifiManager.startScan() use it yields different values after every 6 seconds. How to force it to get new values of scan sooner? I really need to get new result as soon as possible, ideally every 10ms. Is it possible somehow? At this moment, I´m using this code:

wifi.startScan();
    vysledek = wifi.getScanResults();
    int sizeList = vysledek.size();
    for (int a = 0; a < sizeList; a++) {
        // porovnani vysledku s pripojenou ssid//
        if (vysledek.get(a).SSID.equalsIgnoreCase(ssid)) 
        {
            tw5.setText(vysledek.get(a).SSID);
            tw6.setText(vysledek.get(a).BSSID);
            tw7.setText(String.valueOf(vysledek.get(a).level));
            tw8.setText(String.valueOf(System.currentTimeMillis()));
        }
    }

    sleep();

    wifi.startScan();
    vysledek = wifi.getScanResults();
    sizeList = vysledek.size();
    for (int a = 0; a < sizeList; a++) {
        // porovnani vysledku s pripojenou ssid//
        if (vysledek.get(a).SSID.equalsIgnoreCase(ssid)) 
        {
            tw9.setText(vysledek.get(a).SSID);
            tw10.setText(vysledek.get(a).BSSID);
            tw11.setText(String.valueOf(vysledek.get(a).level));
            tw12.setText(String.valueOf(System.currentTimeMillis()));
        }
    }

    sleep();

Where sleep(); is:

public void sleep()
    {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

Output now is: enter image description here

as you can see, I call wifi.startScan(); everytime I want to get new results but it gives me same results as before until 6 seconds is gone. After 6 seconds signal level value changes. Please help me with that :) Thanks

0

There are 0 best solutions below