Obtain the mac address - Android Network

Android examples for Network:Mac Address

Description

Obtain the mac address

Demo Code


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

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

public class Main {
    /**//from  w ww .  ja va 2 s . c  om
     * 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 Tutorials