简体   繁体   中英

List of connected hotspot devices

I would like to retrieve the IP addresses of all devices connected to the WiFi hotspot of my smartphone. In Android 10 and below, I was able to get this list by executing the following piece of code:

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;
     }
}

However, it seems the IP command is no longer working in Android 11 ( https://developer.android.com/training/articles/user-data-ids#mac-11-plus )

The ip command does not return information about interfaces.

Is there any other way to obtain the IP address of a connected client in Android 11?

just this morning I tried that command "ip neigh show" using Termux app on an Android 11 phone and it worked and gave me results of neighbours....

Life-saving solution, considering that Android 10 + won't give you access to "/proc/net/arp" file anymore. Working on Android11, Samsung S10 and Samsung M12.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM