getMacAddress() returns null in Android 11? How to get mac address for Android 11?

Viewed 1734
{
    try {
        List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
        for (NetworkInterface nif : all) {
            if (!nif.getName().equalsIgnoreCase("wlan0")) continue;

            byte[] macBytes = nif.getHardwareAddress();
            if (macBytes == null) {
                macTestResultString = "";
            }
        }
    } catch (Exception ex) {
        Log.e(App.TAG, EXCEPTION + ex.getMessage());
    }
    return macTestResultString;
}
1 Answers

Getting mac address on device api more than 10 is almost impossible. Android's new security restriction no longer allow to access mac address read here. Why do you need the mac address mention the reason might be there is some other solution that may help.

Related