0

How can I find the IP address of the an HTC incredible connected to Verizon's network? My other question - do I have to make any changes to my App to run it on a cellular network? Till now the App was running on a Nexus One connected to a local Wi-Fi network.

Thanks.

Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161

4 Answers4

1

Through mobile network, to check your IP run the command below:

ifconfig rmnet0

or application like 'Android Status' can be handy. Get it from the market.

Boyi
  • 76
  • 2
  • 3
0
  1. To get IP address info look at this example. Might need a tweak for your CDMA.

  2. You need not modify anything to get it working on Mobile n/w

Vinay
  • 2,395
  • 3
  • 30
  • 35
  • I know how to get the IP assigned by the Wi-Fi network. I'm interested in the IP that is assigned by the mobile service provider (Verizon in this case.) – Soumya Simanta Aug 17 '10 at 14:23
0

You can use NetworkInterface.getNetworkInterfaces();, then addresses = intf.getInetAddresses(); to enumerate all the IP addresses on all the interfaces. You're looking for an address associated with a PDP.

That should work. I'm currently looking for a neater way.

Philip Pearl
  • 1,523
  • 16
  • 26
0

To get the internal IP Address you can use the following snippet of code:

Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();

while (networkInterfaces.hasMoreElements()) {
  NetworkInterface networkInterface = networkInterfaces.nextElement();
  Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();

  while (inetAddresses.hasMoreElements()) {
    InetAddress inetAddress = inetAddresses.nextElement();

    byte[] address = inetAddress.getAddress();
  }
}

Note: This will return the private network IP Address. If you want the public IP Address you will need to use STUN (try jSTUN).

Hope that helps!

jagsaund
  • 2,389
  • 18
  • 16