How to get the Android Emulator's IP address?


Question

I want to get the currently running Android Emulator's IP address through code. How can it be achieved?

1
66
11/5/2012 1:29:39 PM

Accepted Answer

Just to clarify: from within your app, you can simply refer to the emulator as 'localhost' or 127.0.0.1.

Web traffic is routed through your development machine, so the emulator's external IP is whatever IP has been assigned to that machine by your provider. The development machine can always be reached from your device at 10.0.2.2.

Since you were asking only about the emulator's IP, what is it you're trying to do?

139
11/12/2009 2:07:13 PM

If you do truly want the IP assigned to your emulator:

adb shell
ifconfig eth0

Which will give you something like:

eth0: ip 10.0.2.15 mask 255.255.255.0 flags [up broadcast running multicast]

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon