I have a problem that I couldn't find my wifi hotspot ssid in my Android system.
I found many information from google, but nothing helpful.
Please help me to solve it.
Asked
Active
Viewed 5.2k times
19

naXa stands with Ukraine
- 35,493
- 19
- 190
- 259

solar
- 335
- 2
- 6
- 13
-
What have you tried so far, other than fruitless Google searches? Have you looked through the [WifiManager API documentation](http://developer.android.com/reference/android/net/wifi/WifiManager.html)? – Justin ᚅᚔᚈᚄᚒᚔ Sep 29 '11 at 15:22
-
Oh~the API always gets connection ssid, not my current system ssid – solar Sep 29 '11 at 15:40
-
3Welcome to SO! This is not a forum; __this is a questions and answer site, and I'm afraid your post isn't really a question, because [real questions have answers, not items or ideas or opinions](http://blog.stackoverflow.com/2011/01/real-questions-have-answers/).__ [Please read the FAQ for more information.](http://www.stackoverflow.com/faq) – Sep 29 '11 at 18:28
-
What do you mean by "system ssid"? – VinceFR Jun 01 '12 at 14:07
-
he's right. So do you solve it out? :D – gumuruh Aug 10 '14 at 14:59
3 Answers
52
You can use WifiManager and WifiInfo for getting Wifi SSID
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
Log.d("wifiInfo", wifiInfo.toString());
Log.d("SSID",wifiInfo.getSSID());
Also add Permission in your Manifest file.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
</uses-permission>

Lalit Poptani
- 67,150
- 23
- 161
- 242
-
3Oh~this method I tried before, it just can get my current connection ssid, but can't get my wifi hotspot ssid in my android system – solar Sep 29 '11 at 15:50
-
i think he should noted that this might be working only if he turned on his WIfi first. – gumuruh Aug 10 '14 at 15:00
-
4Doesn't work on Android 8.1. `# dumpsys wifi | grep mWifiInfo` gives `mWifiInfo SSID:
, BSSID: – Mygod Jan 04 '18 at 14:21, MAC: ..., Supplicant state: DISCONNECTED, RSSI: -127, Link speed: -1Mbps, Frequency: -1MHz, Net ID: -1, Metered hint: false, score: 0` -
Same for me, does not work on Android 7.1.1, it returns a NetworkInfo but with SSID
– Stéphane Feb 22 '19 at 12:31
9
Here: http://www.androidjavadoc.com/2.3/android/net/wifi/WifiManager.html is the full documentation on the WifiManager.
Note that some of the methods are only available through inspection, as is the method you need getWifiApConfiguration
.
WifiManager wifimanager = (WifiManager) getSystemService(WIFI_SERVICE);
Method[] methods = wifimanager.getClass().getDeclaredMethods();
for (Method m: methods) {
if (m.getName().equals("getWifiApConfiguration")) {
WifiConfiguration config = (WifiConfiguration)m.invoke(wifimanager);
// here, the "config" variable holds the info, your SSID is in
// config.SSID
}
}
O, and because this stuff is marked hidden, it can change or be completely removed in any future version of Android. So, don't rely on it too much on "official" apps, unless you make that very clear.

Bart Friederichs
- 33,050
- 15
- 95
- 195
-
that's make sense. BUt I wonder. How could we change our own device name ? through the UI Settings of course we know, but through code, do u have clue @BartFriederichs? – gumuruh Aug 10 '14 at 15:37
-
@gumuruh I have been fiddling with that, and it is possible by setting the configuration. Use inspection to get to the right calls. Note though that those parts of the API can be changed or removed at any time and break your app. Use at your own risk. – Bart Friederichs Aug 21 '14 at 15:45
-
This API is also protected by a permission that's signature protected now. Only system apps can call it. – Mygod Jan 04 '18 at 14:22
0
Have you tried using WifiInfo.getSSID()
?
http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getSSID%28%29

Dan Nestor
- 2,441
- 1
- 24
- 45
-
I tried before, it just can scan other wifi hotspots, not my current android system ssid – solar Sep 29 '11 at 15:42
-
The documentation states that this function returns the SSID of the _current_ network. – Dan Nestor Sep 29 '11 at 16:43
-
I need to get the wifi hospot ssid which I set in my android system, not the current connection ssid in the network. – solar Sep 29 '11 at 16:46
-
If this is what you mean, try WifiManager.getConfiguredNetworks() http://developer.android.com/reference/android/net/wifi/WifiManager.html#getConfiguredNetworks() – Dan Nestor Sep 29 '11 at 18:11
-
2He needs to find a way to get the SSID of the network his Android device is broadcasting, not the SSID of the network he is connected to, if I understand this correctly – MattC Jun 12 '12 at 21:03