If you ever wonder how to get the WiFi Router name your Android device is connected to, this is what you are required:
Also add the following permissions to your manifest:
Have fun.
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.
error getActivity()
ReplyDeleteDepends where you call this from... :)
Delete