10

Is it possible to stop wifi scan started with wifiMgr.startScan() ? I browse some posts and read about using thread to give intervals between each result delivery. But if I want to completely stop the process, how can I achieve it?

Jørgen R
  • 10,568
  • 7
  • 42
  • 59
springrolls
  • 1,331
  • 1
  • 14
  • 40
  • My wild guess would that it only runs for a little bit and then returns the results, it probably doesn't just run forever. That's a total guess though. – Falmarri Dec 21 '10 at 16:18
  • 1
    no, it runs continuously. i don't measure the interval, but having read this source code, http://hi-android.info/src/com/android/settings/wifi/WifiSettings.java.html i think there are some parameters affecting the update interval. so maybe it is not possible to completely stop the process. well, i hope i'm right. – springrolls Dec 22 '10 at 09:19

2 Answers2

17

I found the answer a few days ago. Simply unregister the receiver. I don't know if it is the best way to go, but it works.

springrolls
  • 1,331
  • 1
  • 14
  • 40
  • Have you tried SO search feature? I found [this](http://stackoverflow.com/questions/6529276/android-how-to-unregister-a-receiver-created-in-the-manifest) :-) – springrolls Nov 15 '13 at 08:40
  • 3
    I don't think this is correct. Unregistering the receiver simply means you're ignoring the scan results, not stopping the scan. If you re-register the receiver *without* calling startScan again, you'll see the scan results are still flowing in. (At least that's what I'm seeing on a 4.3 device) – wirbly Oct 10 '14 at 13:17
  • wirbly you are correct. I posted a question about it http://stackoverflow.com/questions/29390414/android-wifimanager-and-scanning-battery-performance – DritanX Apr 01 '15 at 12:44
  • Doesnt solve my problem. I want to STOP the scan because it appears to be causing conflicts with scanning for Bluetooth LE devices. Unregistering the receiver only stops one getting the results! The scan keeps going. – Brian Reinhold Feb 15 '18 at 00:31
0

I have found abortBroadcast(); to work. The strange thing is that I did not need to stop it initially as it only ran once each time I called startscan.