I need to find a way to get the SSID of the network that my Android device is shared (My device is being a portable wifi hotspot).
Not the SSID of the network I connected to.
thanks
Join Stack Overflow to learn, share knowledge, and build your career.
I need to find a way to get the SSID of the network that my Android device is shared (My device is being a portable wifi hotspot).
Not the SSID of the network I connected to.
thanks
I finally found that there are some hidden method about getting/setting wifiAP mode in android WifiManager class. In WifiManager class, getWifiApConfiguration could be invoke to get the configuration in which the SSID of wifiAp could be found.
I know OP has already answered his/her own question, but it wasn't too clear for me, so I'll just post my complete solution here for future people that got here:
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
Method[] methods = wifimanager.getClass().getDeclaredMethods();
for (Method m: methods) {
if (m.getName().equals("getWifiApConfiguration")) {
WifiConfiguration config = (WifiConfiguration)m.invoke(wifimanager);
String ssid = config.SSID;
String bssid = config.BSSID;
//or other info about the current hotspot, accessible through config
}
}
Note: you would need the following permissions:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />