title: Retrieving MAC Address Programmatically - Android
body: <p>I'm having an issue with retrieving the MAC address of the device programatically, before anyone mentions anything about other posts I have read them already such as: 
  <a href="https://stackoverflow.com/questions/10831578/how-to-find-mac-address-of-an-android-device-programatically">How to find MAC address of an Android device programmatically</a></p>
  
  <p>however I tried using the code with my own application and tested it with a simple log.d, only to find that it is returning nothing. The message of "seeing if this works shows" but nothing else. So i am presuming the mac address is null.</p>
  
  <pre><code>Log.d("seeing if this works", macAddress2);
  </code></pre>
  
  <p>The code of what I have done is shown here:</p>
  
  <pre><code>//Set onclick listener for the Get Mac Address button
          getMac.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                  WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                  WifiInfo wInfo = wifiManager.getConnectionInfo();
                  String macAddress2 = wInfo.getMacAddress();
  
                  macAddress.setText(macAddress2);
              }
          });
  </code></pre>