title: Android Find the device's ip address when it's hosting a hotspot
body: <p>I need to find the device's ip address when it's hosting a hotspot. I've used this code so far :</p>
  
  <pre><code>//if is using Hotspot
  for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
      NetworkInterface intf = en.nextElement();
      if (intf.getName().contains("wlan")) {
          for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
              InetAddress inetAddress = enumIpAddr.nextElement();
              if (!inetAddress.isLoopbackAddress() &amp;&amp; (inetAddress.getAddress().length == 4)) {
                  return inetAddress.getHostAddress();
              }
          }
      }
  }
  </code></pre>
  
  <p>This works quite fine but the wifi <code>NetworkInterface</code> name differs on some devices. So I have to find the device's wifi <code>NetworkInterface</code> name (for its hotspot) first. How can I find this name? Or is there a better approach to find the device's ip address? </p>
  
  <p>/// Finding the right ip address by the MAC also doesn't seem to work</p>