Find out local IP adress

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

Find out local IP adress

Postby Luki » Thu Aug 06, 2009 2:35 pm

Hi guys
I'm executing this code on my G1 (not emulator) to find out my own IP adress. But it always gives me back 127.0.0.1. How can I find out my real IP without querying an internet host like www.google.com (My application needs to work in an local LAN without Internet connection).

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. Toast.makeText(this, "Local adress is " + InetAddress.getLocalHost().getHostAddress(), Toast.LENGTH_LONG).show();
  5.  
  6.  
  7.  
  8.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4



Thanks for your help, cheers
Luki
Developer
Developer
 
Posts: 32
Joined: Fri Jul 24, 2009 12:59 pm

Top

Postby Luki » Thu Aug 06, 2009 7:17 pm

In the meanwhile i've found a reliable way to detect the real IP of you device:
http://www.droidnova.com/tag/localhost.
Luki
Developer
Developer
 
Posts: 32
Joined: Fri Jul 24, 2009 12:59 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 5 guests