【问题标题】:List of connected hotspot devices已连接热点设备列表
【发布时间】: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


    【解决方案1】:

    就在今天早上,我在 Android 11 手机上使用 Termux 应用程序尝试了“ip neigh show”命令,它工作并给了我邻居的结果....

    【讨论】:

      猜你喜欢
      • 2017-10-09
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      • 2022-10-08
      • 2014-12-17
      • 2011-04-10
      • 1970-01-01
      相关资源
      最近更新 更多