Search Unity

Retrieving MAC address on Android device

Discussion in 'Android' started by johnnydj, Jun 30, 2013.

  1. johnnydj

    johnnydj

    Joined:
    Apr 20, 2012
    Posts:
    211
    Is there a way to retrieve the MAC of a wireless module in an Android device ?

    On PC I was able to retrieve my MAC, but the same script on Android does not work.
    Here's how I'm using it on PC:
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Net;
    4. using System.Net.NetworkInformation;
    5.  
    6.  
    7. public class MACBind : MonoBehaviour {
    8.     public string PhysicalAddress;
    9.    
    10.     public void Start(){
    11.         DisplayTypeAndAddress();
    12.     }
    13.    
    14.     public void DisplayTypeAndAddress()
    15.     {
    16.         NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    17.         PhysicalAddress = nics[0].GetPhysicalAddress().ToString();
    18.                 Debug.Log("MAC: " + PhysicalAddress );
    19.          }
    20.  
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
  3. johnnydj

    johnnydj

    Joined:
    Apr 20, 2012
    Posts:
    211