Monitoring Active Connection Details

Once an active network connection has been established, use the getConnectioninfo method on the Wi-Fi Manager to find information on the active connection's status. The returned Wifiinfo object includes the SSID, BSSID, Mac address, and IP address of the current access point, as well as the current link speed and signal strength.

Listing 13-17 queries the active Wi-Fi connection.

LISTING 13-17: Querying the active network connection Available for downloadon Wifiinfo info = wifi.getConnectionInfo(); Wrox.com if (info.getBSSID() != null) {

int strength = WifiManager.calculateSignalLevel(info.getRssi(), 5);

int speed = info.getLinkSpeed();

String units = WifiInfo.LINK_SPEED_UNITS;

String ssid = info.getSSID();

String cSummary = String.format("Connected to %s at %s%s. Strength %s/5"

ssid, speed, units, strength);

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