How to get Android local IP(192.168.1.18)? not 127.0.0.1.

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

How to get Android local IP(192.168.1.18)? not 127.0.0.1.

Postby infotomrk » Thu Oct 16, 2008 10:54 am

How to get Android local IP(192.168.1.18)? not 127.0.0.1..

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. String myIP = java.net.InetAddress.getLocalHost().getHostAddress();
  3.  
  4.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


return my System local IP as 192.168.1.18

it's working in java - static method

but... Like that i coundn't get in Android application. It return as
127.0.0.1
I hv add permission for internet in AndroidManifest.xml file too... but still ?????

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <uses-permission android:name="android.permission.INTERNET" />
  3.  
  4.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4




I have tried
- InetAddress.getLocalHost();
- NetworkInterface
- Socket {Some prog too}
- ???

Note : i'm working in Windows(Vista SP1) OS

Could any one find ans for this....?
MRK Think BIG
infotomrk
Freshman
Freshman
 
Posts: 3
Joined: Fri Sep 12, 2008 3:59 pm
Location: India

Top

Postby zhufan » Thu Nov 27, 2008 4:28 pm

hello
http://code.google.com/android/referenc ... html,there is helpfull for you ,see 'Emulator Networking'
zhufan
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed Nov 26, 2008 3:18 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 6 guests