Android Scan for Wifi networks

前端 未结 5 711
北荒
北荒 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:15

    Well i dont know anything about speeding up the process, it could just be that it takes a while to find the wifi signals (that, or your wifi is not turned on... which is something that your program should check for before it starts). However, one thing you can do to improve your workflow would be to do all of this in a different activity using startActivityForResult(). That way your "main" activity will be able to act on that data after it's done and you wont have to eat up the cpu on a while loop.

    public void onActivityResult(....){
       switch(retCode){
       case SCAN_ACTIVITY:{
             //do stuff
          }
       }
    }
    

提交回复
热议问题