【发布时间】:2021-02-11 14:09:30
【问题描述】:
我想检索连接到我智能手机 WiFi 热点的所有设备的 IP 地址。 在 Android 10 及更低版本中,我可以通过执行以下代码来获取此列表:
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("ip neigh show");
proc.waitFor();
int exit = proc.exitValue();
InputStreamReader reader = new InputStreamReader(proc.getInputStream());
BufferedReader buffer = new BufferedReader(reader);
String line;
while ((line = buffer.readLine()) != null) {
String[] splits = line.split(" ");
if (splits.length < 4) {
continue;
}
if(!splits[0].contains("192.168.43.")) {
Log.d("IP", splits[0]);
continue;
}
}
但是,IP 命令似乎在 Android 11 中不再有效 (https://developer.android.com/training/articles/user-data-ids#mac-11-plus)
The ip command does not return information about interfaces.
Android 11 中是否有其他方法可以获取已连接客户端的 IP 地址?
【问题讨论】:
标签: java android hotspot tethering