This question already has an answer here:
- Determine device public ip 13 answers
I am developing an application in android 2.1 and I want to display the external IP. How could I do this? Thanks in advance.
This question already has an answer here:
I am developing an application in android 2.1 and I want to display the external IP. How could I do this? Thanks in advance.
http://api.externalip.net/ip will return your ip in simple api format
You can read more about getting the external ip here: http://www.externalip.net/api
I don't think that there is a way to do it programmatically but you could call up a site like http://www.whatismyip.com/ and then strip out the IP from the page. You might want to find a site that offers an API and supports 3rd party calls.
Take a look at this code snippet: