The only way I found it for now is:

Socket conn = new Socket("www.google.com", 80);
String ipAddress = Socket.getLocalAddress().toString();
Conn.Close;

Of course you need to catch for the exceptions. It returns the address in
the form "name/IP", you must parse the string to get the second piece.

Marcio Alexandroni
www.cialogica.com
w  Tel. 55 11 3717-2345
   Cel. 55 11 9989-8316
[EMAIL PROTECTED] 
 marcioalexandroni

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Peter
Sent: Sunday, December 07, 2008 05:32
To: Android Developers
Subject: [android-developers] Re: How to find out what the IP address of the
Android device is?


Not that this is legit or anything but you could retrieve a site such
as cmyip.com and just extract the IP from the html. You could also
setup a server yourelf to hand back the IP when the device connects?
(you could also use the IP information for statistics =p )

On Dec 5, 4:18 pm, Qualyxx <[EMAIL PROTECTED]> wrote:
> There is a DhcpInfo class but it does not tell you where you can
> retrieve the DhCpInfo from.
>
> I would like to establish a ServerSocket and let other Android device
> to connect to it and I need to publish the IP address of the device.
>
> any hint?
>
> Thanks,
>
> Yang



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to