get Wifi MAC address - Android android.net.wifi

Android examples for android.net.wifi:Wifi Address

Description

get Wifi MAC address

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 getWifiLYMAC(Context context) {
        WifiManager mWifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiinfo = mWifiManager.getConnectionInfo();
        if (wifiinfo != null && wifiinfo.getBSSID() != null
                && !wifiinfo.getBSSID().equals("")) {
            return wifiinfo.getBSSID().replace(":", "-");
        }//from  w  w w.  j  av a 2 s.c  o  m
        return "00-00-00-00-00-00";
    }

}

Related Tutorials