1

I'm trying to build this app which scans and connects to wireless networks. I used a sample code from the following link

http://www.androidsnippets.com/scan-for-wireless-networks

But the list it returns seem to contain duplicates. Also can someone give me an example as to how to connect to a particular network programatically please?

Thank you

Mr.Noob
  • 1,005
  • 3
  • 24
  • 58

1 Answers1

2

You already have the list with you, only issue i guess you are having is it has duplicate which can be removed easily. Now to connect to a particular network Refer to this

Hope this helps !!

Community
  • 1
  • 1
  • your example seems to work! but how can i remove the duplicates? – Mr.Noob Feb 18 '13 at 10:45
  • @Mr.Noob I guess you are using the link mentioned in your question to fetch list of wifi networks, there `wifiList = mainWifi.getScanResults();` is used to get list of network, you can use [set](http://developer.android.com/reference/java/util/HashSet.html) and then iterate over it to build your menu. Something like this `Set se = new HashSet(wifiList);`. Using set will eliminate duplicates. – Alankar Srivastava Feb 18 '13 at 11:04
  • yeah I get what you mean! but why does it return duplicate values? is there a way of returning the list of wifi networs without duplicates? – Mr.Noob Feb 18 '13 at 12:16
  • 1
    Hey duplicates occur because at times in offices and other public places there are multiple routers with same SSID to strengthen your connectivity. Hence what you can do is prepare a hashmap with SSID and strength of that SSID and then store the results with max strength. This will solve the problem of eliminating duplicates and give you results with max strength – unrealsoul007 Apr 01 '15 at 10:07