How to get the ip-address of a computer in the Android emulator via code

I use the code for this link How do I get the IP address of a device from code? but getting an ip address different from my machine .... how can I get the ip address of my machine on an Android emulator.

early

+3
source share
2 answers

Check this out if you want to access the host machine.

Another solution is to run this on the shell

$ adb shell am start -a android.intent.action.WEB_SEARCH -e request "what is my ip"

will display your IP system

+3
source

import java.net package;

and write the code,

try {
InetAddress thisIp =InetAddress.getLocalHost();
System.out.println("IP:"+thisIp.getHostAddress());
}
catch(Exception e) {
e.printStackTrace();
}
0
source

All Articles