arraylist - Android WifiManager: How to store wifi scan results for multiple scans -
i need multiple scans using wifimanager. have following code scan once , store results in access_points, can suggest efficient code store results of multiple scans?
wifi = (wifimanager) this.getsystemservice(wifi_service); list<scanresult> access_points = wifi.getscanresults();
this wrong way results. if list<scanresult> access_points = wifi.getscanresults();
it return old results you.
to wifi scan results instance of wifimanager in first line , then
wifimanager wifimanager = (wifimanager) context.getsystemservice(context.wifi_service); wifimanager.getscanresults(); // above async call , results available system broadcast scan_results_available intent , need set `broadcastreceiver` it. // , when catch intent, results using list<scanresult> results = wifimanager.getscanresults();
to results multiple times or multiple scans need call wifimanager.startscan()
multiple times , obtain fresh results using list<scanresult> results = wifimanager.getscanresults();
when catch intent scan_results_available
. can use timer or use post method of handler.
Comments
Post a Comment