title: How to get MAC address from an Android device?
body: <p>I have an Android application that works on a single phone. In order to work on a single device, I need to get the MAC address or Android ID. I decided to get the MAC address because the app needs to connect on a specified WiFi network.</p>
  <p>How to get the MAC address from an Android device?</p>
  <pre><code>WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
  WifiInfo info = manager.getConnectionInfo();
  String address = info.getMacAddress();
  </code></pre>
  <p>Currently I'm using this but it is not stable.</p>
  <p>When the app restarts, it returns <code>02:00:00:00:00:00.</code> and crashes.</p>