Good day. I want to get the MAC address of wifi.

In Manifest prescribed:

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

Calling requestPermissions(new String[]{Manifest.permission.ACCESS_WIFI_STATE},1);

And here I catch

  @Override public void onRequestPermissionsResult(int String permissions[], int[] grantResults) { switch (requestCode) { case 1: if (grantResults.length > && grantResults[0] PackageManager.PERMISSION_GRANTED) { WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE); final WifiInfo info = manager.getConnectionInfo(); String address = info.getMacAddress(); Toast.makeText(getApplicationContext(),"ПРАВА ПОЛУЧЕНЫ mac: " + address,Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(),"ПРАВА НЕ ПОЛУЧЕНЫ",Toast.LENGTH_LONG). } return; } } } 

The message displays that the rights are received, but MAC = "02: 00: 00: 00: 00: 00"

How to get MAC on Android 6?

    2 answers 2

    You can’t get it on Android 6 https://developer.android.com/intl/ru/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id they turned off this feature ((and return the default value is "02: 00: 00: 00: 00: 00"

    • I need my mac address, mac adapter, which is in the device (phone) and as a rule, we don’t change it without root. Mac is needed to register the application. - Scream Night
    • @ScreamNight, in Android 6, it was forbidden to receive MAC addresses for WIFI and Bluetooth. You cannot get it without Root (for Bluetooth, while there is a way around this limitation) - Vladyslav Matviienko

    In Android 6 you can get poppy without root.

      List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface nif : all) { if (!nif.getName().equalsIgnoreCase("wlan0")) continue; byte[] macBytes = nif.getHardwareAddress(); if (macBytes == null) { return ""; } StringBuilder res1 = new StringBuilder(); for (byte b : macBytes) { res1.append(String.format("%02X:",b)); } if (res1.length() > 0) { res1.deleteCharAt(res1.length() - 1); } return res1.toString(); }