0

When trying to query the PhysicalAddress of a NetworkInterface in C# (in Unity) specifically on Android, it returns empty rather than the mac address. On Windows (In the Unity Editor) it works properly. How can I actually get the physical address?

public static void GetAddresses()
{
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();

    foreach (NetworkInterface adapter in nics)
    {
            Debug.Log($"{adapter.Name} - {adapter.GetPhysicalAddress()}");
    }
}

This returns the following in the log on Android (Samsung, specifically) devices:

wlan0 - 
dummy0 - 
lo - 
rmnet_data1 - 

Ultimately, I'm trying to get a "primary" mac address to tie to a user.

  • 2
    "MAC addresses are globally unique, not user-resettable, and survive factory resets. For these reasons, to protect user privacy, on Android versions 6 and higher, access to MAC addresses is restricted to system apps. Third-party apps can't access them." https://developer.android.com/training/articles/user-data-ids#mac-11-plus – ecle Sep 18 '22 at 14:11
  • 2
    Because every MAC address can now be randomized, there is no way to obtain the true fixed hardware MAC address of any interface (WIFI, Bluetooth, Network) on Android. https://stackoverflow.com/questions/36180407/why-the-address-of-my-bluetoothdevice-changes-every-time-i-relaunch-the-app – ecle Sep 18 '22 at 14:25

0 Answers0