title: JAVA get IP address
body: <p>I am developing an android app and need to know the device ip.</p>
  
  <p>I have tried with <code>Inet4Address.getLocalHost().getHostAddress()</code> but it gives <code>127.0.0.1</code>.</p>
  
  <p>So I am establishing a HTTP connection with a server that send the ip back.</p>
  
  <p>But this process creates an issue when there is a gateway between the device and the requested server. In this case I don't get the network's device ip instead I get the gateway ip.</p>
  
  <p>Please help.</p>
  
  <p>Thanks.</p>