连接的热点设备列表

问题描述

我想检索连接到我智能手机 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 地址吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)