Android Mac Address Get getMac(Context context)

Here you can find the source of getMac(Context context)

Description

Obtain the mac address

Parameter

Parameter Description
context a parameter

Declaration

public static String getMac(Context context) 

Method Source Code

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

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

public class Main {
    /**/*from  w w w.j  a v  a2 s .  c  o  m*/
     * Obtain the mac address
     * @param context
     * @return
     * @author Dwyane Mo
     * @CreateDate 2013-5-14 
     */
    public static String getMac(Context context) {
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        String macAddress = wifiInfo.getMacAddress();
        return macAddress;
    }
}

Related

  1. getMACAddress(String interfaceName)