我想以编程方式找到它们通过WiFi连接到Android设备或仿真器的计算机的IP地址。我该怎么做呢?
I would like to programmatically find the IP addresses of computers which are connected via WiFi to an Android device or emulator. How do I do this?
可以共享logcat的,我怀疑可能有一些其他的issue.Try这个code(这是)一个示例应用程序来检查只有当无线网络连接的IP地址正在
Can you share the logcat, I suspect there might be some other issue.Try this code (as is) in a sample application to check only if Wi-Fi IP address is working
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
String ip = null;
ip = String.format("%d.%d.%d.%d",
(ipAddress & 0xff),
(ipAddress >> 8 & 0xff),
(ipAddress >> 16 & 0xff),
(ipAddress >> 24 & 0xff))