code: public static InetAddress getLocalHost() throws UnknownHostException {
          String local = Libcore.os.uname().nodename;
          try {
            return impl.lookupAllHostAddr(local, NETID_UNSET)[0];
          } catch (UnknownHostException e) {
            try {
              // iOS devices don't map the hostname to an ip.
              return impl.lookupAllHostAddr("127.0.0.1", NETID_UNSET)[0];
            } catch (UnknownHostException e2) {
              throw e;
            }
          }
      }
docs: Returns the address of the local host. This is achieved by retrieving
  the name of the host from the system, then resolving that name into
  an <code>InetAddress</code>.
  
  <P>Note: The resolved address may be cached for a short period of time.
  </P>
  
  <p>If there is a security manager, its
  <code>checkConnect</code> method is called
  with the local host name and <code>-1</code>
  as its arguments to see if the operation is allowed.
  If the operation is not allowed, an InetAddress representing
  the loopback address is returned.
  
  @return     the address of the local host.
  
  @exception  UnknownHostException  if the local host name could not
  be resolved into an address.
  
  @see SecurityManager#checkConnect
  @see java.net.InetAddress#getByName(java.lang.String)