Duplicate question - How to get my wifi hotspot ssid in my current android system Sorry for duplicate this qustion, but it still doesn't have the answer. My mobile in tethering mode, so I want to know SSID of it. How can I find this one? Thanks a lot!
Asked
Active
Viewed 5,538 times
2 Answers
3
It's a bit late but i recently managed to get the SSID of the device's hotspot. It's working on my Galaxy Nexus, but haven't tested it quite much.
public static WifiConfiguration getWifiApConfiguration(final Context ctx) {
final WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
final Method m = getWifiManagerMethod("getWifiApConfiguration", wifiManager);
if(m != null) {
try {
return (WifiConfiguration) m.invoke(wifiManager);
} catch(Exception e) {
}
}
return null;
}
private static Method getWifiManagerMethod(final String methodName, final WifiManager wifiManager) {
final Method[] methods = wifiManager.getClass().getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(methodName)) {
return method;
}
}
return null;
}
Just call getWifiApConfiguration(getActivity()).SSID to get the hotspot name. Nullpointer check is recommended before ;)

Daniel Amerbauer
- 573
- 1
- 4
- 8
-
After Android O, this code require specific permission (source :https://stackoverflow.com/a/15121282/4965913). Anybody know how to make this code works after Android O please ? – Maxime Esprit Aug 31 '20 at 14:33
-
I found this to get some information : https://stackoverflow.com/a/45996578/4965913 – Maxime Esprit Aug 31 '20 at 15:08
2
WifiManager mng = (WifiManager)context.getSystemService(Context.WIFI_SERVICE).
String currentSSID = mng.getConnectionInfo().getSSID()

VinceFR
- 2,551
- 1
- 21
- 27
-
This answer was described in duplicate question. As it answered it can't get my wifi hotspot ssid! – Nolesh Jun 01 '12 at 14:07
-
-
Exactly@Nolesh. We want the ssid for wifi ap not wifi router. Did you find any solution? – Pushan Gupta Apr 23 '17 at 09:08