code: private static String getMacAddress(@NonNull Context context) {
  
          if (isWifiStatePermissionGranted(context)) {
              WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
              if (wifiManager != null) {
                  WifiInfo wifiInfo = wifiManager.getConnectionInfo();
                  if (wifiInfo != null) {
                      return wifiInfo.getMacAddress();
                  }
              }
          }
  
          return null;
      }
docs: Gets device mac address.
  
  @param context App context.
  @return Device mac address.