get Wifi Mac - Android Phone

Android examples for Phone:wifi

Description

get Wifi Mac

Demo Code


//package com.java2s;
import android.content.Context;

import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

public class Main {
    public static String getWifiMac(Context context) {
        String address = "";
        try {/*  w  ww .j  a va2s  . co  m*/
            WifiManager wifi = (WifiManager) context
                    .getSystemService(Context.WIFI_SERVICE);
            WifiInfo info = wifi.getConnectionInfo();
            address = info.getMacAddress();
        } catch (Exception e) {
            // TODO: handle exception
        }
        return address;
    }
}

Related Tutorials