Android tutorial: check WiFi network name

18 05 2013

How to check if the Android device is connected to wireless network and what is this networks’ name (SSID)?

You can get connection info with the use of WifiManager class in just few lines of code:

public String getWifiName(Context context) {
	String ssid = "none";
	WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
	WifiInfo wifiInfo = wifiManager.getConnectionInfo();
	if (WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState()) == NetworkInfo.DetailedState.CONNECTED) {
		ssid = wifiInfo.getSSID();
	return ssid;

Permisson required

Please note that accessing WiFi state requires permission in AndroidManifest.xml:

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

What else you can check?

With WifiInfo objects comes few more details like: link speed, MAC Address or signal strength. Check the WifiInfo documentation here.

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!




6 responses

15 07 2014

thanks for the article… but is it possible
to detect other user device
when they turned on the WIFI without connected to any network first?

I want to detect their existance around me. but how to do it in android?

15 07 2014
Jacek Milewski

only wifi router can detect that. or you can have an app that will respond to broadcast messages and will enable network discovery.

not by default, simple means, but of course possible

15 07 2014

indeed…. I want to achieve that.
Simply when I used this 3 weeks researching ….
Eventually i ended up with NewAer SDK, and LTE Direct SDK….
Which I heard they could make the android device detect other device existance (discovery mechanism)… which is fit to my purpose.

But, do you know? it doesn’t provide any tutorials… sigh. Perhaps if you have,… would you mind to share it into your article? it would be great.

Thanks Jacek Milewski.

15 07 2014
Jacek Milewski

it is quite a big thing for the article. I would have to get few modules from other projects and build it.

16 08 2014
Adam Geller

Check via NetworkInfo for wifi-type if it is connected.
And then use wifiinfo getSSid(). You might want to remove double slashes from returnd SSID

You should check out this application and developer api from

It will help you with your task.

8 03 2015
Karl Jobst

Karl Jobst

Android tutorial: check WiFi network name | Looks OK!

Give Your feedback:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: