Android Scan for Wifi networks

前端 未结 5 762
北荒
北荒 2021-02-02 04:33

I\'m trying to scan for wireless networks and found this helpful source on the net. Unfortunately it\'s not working and I have no idea why. My problem is that I can\'t wait 10 m

5条回答
  •  生来不讨喜
    2021-02-02 05:12

    Where are you putting this code? In the onCreate of an activity?

    The problem is that you're registering a callback which will get called when you receive the scan results, which according to the Android API docs is done in a separate thread, so your busy-waiting loop is achieving nothing in this circumstance except needlessly halting your activity, and if it's during the onCreate that means it never exits the method.

提交回复
热议问题