Thursday, May 24, 2012

Android get Wifi Router Name

If you ever wonder how to get the WiFi Router name your Android device is connected to, this is what you are required:

WifiManager wifiMgr = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiMgr.getConnectionInfo
String name = wifiInfo.getSSID

Also add the following permissions to your manifest:

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Have fun.