If you need to display the connected Wi-Fi name in your application than you just have put this method getConnectedWiFiName in your utility class and call it whenever you need the Wi-Fi network name.
public static String getConnectedWiFiName (Context)
{
try
{
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String name = wifiInfo.getSSID();
return name;
}
catch (Exception e)
{
return " ";
}
}
Don't forget, you should declare the permission in your manifest:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Hope you find it helpfull :)
0 Comment(s)