Search code examples
androidwifiandroid-wifi

How to programmatically bring up list of Wifi networks to connect to?


I'm programming a Nexus 7. In my program I reach a point where I want the user to select a Wifi network to use (either preconfigured or the choice to create a new one). How can I bring up that dialog programmatically?


Solution

  • In order to access the wi-fi list, you may first need to use the wi-fi permissions. Wi-Fi must be turned on first before the Wi-Fi scan can provide a list of results.

    My guess is: ACCESS_WIFI_STATE

    I think the easiest would approach would be to then launch the appropriate intent. ACTION_PICK_WIFI_NETWORK http://developer.android.com/reference/android/net/wifi/WifiManager.html#ACTION_PICK_WIFI_NETWORK

    (May also wish to see: ACTION_WIFI_SETTINGS)