title: Ip address of PC in USB Tethering mode in Android without WIFI, Programatically
body: <p>How can I programatically get the Ip address, default gateway and port number of the PC to which the android phone is connected in USB Tethering mode, without using WIFI Manager?</p>
  
  <p>I used network interfaces, but it doesnt give me the correct information, is there any other way?</p>
  
  <pre><code>for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
              NetworkInterface intf = en.nextElement();
              for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                  InetAddress inetAddress = enumIpAddr.nextElement();
                  if (!inetAddress.isLoopbackAddress()) {
                      address += inetAddress.getHostAddress().toString() ;
                  }
              }
          }
  </code></pre>