【发布时间】:2012-04-12 06:36:09
【问题描述】:
我正在使用此链接的代码How to get IP address of the device from code?,但获取的 ip 地址与我的机器不同..如何在 android 模拟器上获取我的机器的 ip 地址..
提前致谢
【问题讨论】:
标签: android android-emulator ip
我正在使用此链接的代码How to get IP address of the device from code?,但获取的 ip 地址与我的机器不同..如何在 android 模拟器上获取我的机器的 ip 地址..
提前致谢
【问题讨论】:
标签: android android-emulator ip
Check this out如果你想访问主机。
另一种解决方案是在 shell 上运行它
$ adb shell am start -a android.intent.action.WEB_SEARCH -e 查询“我的 ip 是什么”
它会显示你的系统IP
【讨论】:
导入包java.net;
并编写代码,
try {
InetAddress thisIp =InetAddress.getLocalHost();
System.out.println("IP:"+thisIp.getHostAddress());
}
catch(Exception e) {
e.printStackTrace();
}
【讨论】: