How to make timer for access point scan, so that the scan runs every second?android!
I'm doing this application were I do an access point scan to get signal strength values from all APs..I want to make the scan 1 second after another.. Right now i'm implementing this in the following way:
Runnable t = new Runnable() { public void run() { Log.i(TAG3, "startedScan"); wifiManager.startScan(); try { handleScanRe开发者_如何学编程sults(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } mHandler.postDelayed( this, 600 ); } };
protected void setTimer() { mHandler.post(t); }
As you can see this is being done for each 600 miliseconds, although the problem with this timer is that "I guess!" is creating another thread each time it runs. How can I solve this, The aplication starts to be to heavy along the time and I cant interact with it.. Please Help!
startScan() doesn't fire just once, it returns results over a period of time (well that's my experience).
so the best scenario would be: - startScan() - wait for results, I recommend a certain amount of time - then call startScan() again
600ms between every startScan() is just too much for android, I don't think the first results are even returned in such a short timeframe (?)
what's it for? are you trying to determine a location with signal strengths or why would you need to call it every second?
every 5 or 10 should be enough to get results continously
精彩评论