Managing WiFi Configurations

You can use the Wi-Fi Manager to manage the configured network settings and control which networks to connect to. Once connected, you can interrogate the active network connection to get additional details of its configuration and settings.

Get a list of the current network configurations using getConfiguredNetworks. The list of WifiConfiguration objects returned includes the network ID, SSID, and other details for each configuration.

To use a particular network configuration, use the enableNetwork method, passing in the network ID to use and specifying true for the disableAllOthers parameter, as shown in Listing 13-19.

LISTING 13-19: Activating a network connection

Available for download on

// Get a list of available configurations

List<WifiConfiguration> configurations = wifi.getConfiguredNetworks(); // Get the network ID for the first one. if (configurations.size() > 0) {

int netID = configurations.get(0).networkId; // Enable that network. boolean disableAllOthers = true; wifi.enableNetwork(netID, disableAllOtherstrue);

Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment