Hi Regina.. Many Thanks for the codes! :)
Joseph On Thu, Mar 19, 2009 at 5:38 AM, Regina Mitsue Azuma <[email protected]>wrote: > > I was able to get the IP address using the following code: > > public String getLocalIpAddress() { > try { > for (Enumeration<NetworkInterface> en = > NetworkInterface.getNetworkInterfaces(); en > .hasMoreElements();) { > NetworkInterface intf = en.nextElement(); > for (Enumeration<InetAddress> enumIpAddr = > intf.getInetAddresses(); enumIpAddr > .hasMoreElements();) { > InetAddress inetAddress = enumIpAddr.nextElement > (); > if (!inetAddress.isLoopbackAddress()) { > return inetAddress.getHostAddress().toString > (); > } > } > } > } catch (SocketException ex) { > Log.e(S.TAG, ex.toString()); > } > return null; > } > > Regards, > Regina > > On Mar 15, 10:39 pm, Joseph Teo <[email protected]> wrote: > > Hi Folks, > > > > I have a small question. When i'm connected to WIFI, I could use the > > following code to obtain the IP address of the Android phone > > > > WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); > > WifiInfo wifiInfo = wifiManager.getConnectionInfo(); > > int ipAddress = wifiInfo.getIpAddress(); > > > > However, when i'm on the MOBILE (3G) connection, is it still possible to > > obtain the IP address of the Android phone? and if so, can someone post > the > > code snippet (e.g. like above) for getting the IP address when on 3G > > Connection? > > > > Thanks a million! > > > > Rgds, > > Joseph > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

