Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Bug in obtaining MAC Address in Android 7.1

$
0
0

I try to retrieve MAC Address from an Android Device. The following code works both in 7.0 and 7.1 while on Wifi network. On cellular network though works only in 7.0 version of Android.

    var all = Collections.List(NetworkInterface.NetworkInterfaces);
            foreach (NetworkInterface nif in all)
            {
                if (!string.Equals(nif.Name, "wlan0")) continue;

                byte[] macBytes = nif.GetHardwareAddress();
                if (macBytes == null)
                {
                    return "";
                }

                StringBuilder res1 = new StringBuilder();
                foreach (byte b in macBytes)
                {
                    res1.Append(String.Format("{0:X2}:", b));
                }

                if (res1.Length > 0)
                {
                    res1.Remove(res1.Length - 1, 1);
                }
                return res1.ToString();
            }

I have similar issues with the location service which worked on Android 6.0 and stopped working on Android 7.0 so I guess it's an issue of the Android support libraries. Is there a way to update them without crushing the entire system or a workaround to solves these issues?

I use the following versions:

Android Support Libraries: 23.3.0
Xamarin Forms: 2.3.4.247


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>