get Current Wifi Name - Android android.net.wifi

Android examples for android.net.wifi:Wifi Property

Description

get Current Wifi Name

Demo Code

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import java.net.Inet4Address;

public class Main{


    public static String getCurrentWifiName(Context context) {
        WifiManager mWifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = mWifiManager.getConnectionInfo();
        String name = null;/*from www .ja va 2  s . co  m*/
        if (info != null && info.getSSID() != null) {
            name = info.getSSID().replace("\"", "");
            return name;
        }

        return "";
    }

}

Related Tutorials