I have searched everywhere on how to get the external ip address with no avail. I am able to successfully get the local ip address.
In short what i want to do to get the same ip address as when I go on whatip.com or whatismyipaddress.com. However, I do not want to make any calls to the websites, is there a built in way to get this?
Also, I want the external ipaddress if the user is connected to wifi.
For Android The most common way to find it is to head to Settings>Network & Wi-Fi> Select the network you connected with then press Advance to know the information related to IP.
Android. Select Settings from the application menu. Go to About Device > Status. Scroll down and look for the IP Address.
External (Public) IP Address Also, any website that you visit will have access to this IP address. Your external IP address is 172.70. 38.150. Every website also has an IP address of its own, though you never need to know them.
However, I do not want to make any calls to the websites, is there a built in way to get this?
No. This is impossible on most pieces of hardware, including desktops and notebooks, let alone phones. Generally, you are behind some sort of NAT, which defines your "external ip address".
IcanHazIP.com gives you a short and sweet response for the external IP.
However, using that URL on a large number of phones will inevitably yield the same IP for a few devices (for the reason that CommonsWare has already explained).
Idea: The data might be more meaningful if you collect the external IP combined with the local IP. So send a request to IcanHazIP.com followed by the following sample code for the Local IP: http://chandan-tech.blogspot.com/2010/12/finding-ip-address-of-your-android.html
By the way, I've worked on development devices with Modems that were activated by Sprint and their local IP's actually were external IP's
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With