get SSID - Android android.net.wifi

Android examples for android.net.wifi:Wifi SSID

Description

get SSID

Demo Code

import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import java.util.List;

public class Main{

    public static String getSSID(Context context) {
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        boolean wifiEnabled = wifiManager.isWifiEnabled();

        if (wifiEnabled) {
            WifiInfo info = wifiManager.getConnectionInfo();
            return info.getSSID();
        }//w ww .  ja v  a2s  . c  o  m
        return "N/A";
    }

}

Related Tutorials