title: InetAddress.getLocalHost().getHostAddress() returns 127.0.0.1 in Android
body: <p>My application uses multicast to send a beacon in periods along with protocol message and ip of the host joining the multicast group. In android device it is returning 127.0.0.1. I have looked around and found that many people suggested changing a host file. But, in case of android it is not possible in my context. How do I get real IP of the device, not the loopback address..</p>
  
  <pre><code>private void getLocalAddress()
  {
      try {
          String localHost = InetAddress.getLocalHost().getHostAddress();
          servers.add(localHost);
      } catch (UnknownHostException e) {
          e.printStackTrace();
      }
  }
  </code></pre>