Using ARP table we can access IP and MAC of hotspot connected devices in Android 9 and earlier versions. Now from Android 10 permission denied for the same. Kindly suggest how can I access IP and MAC address of connected devices in Android 10. Below Code working in up-to Android 9 Version but not work in Android 10.
BufferedReader br = new BufferedReader(new FileReader("/proc/net/arp"));
String line;
while ((line = br.readLine()) != null) {
String[] clientInfo = line.split(" +");
if(!clientInfo[3].equalsIgnoreCase("type")) {
String mac = clientInfo[3];
String ip = clientInfo[0];
textView.append("\n\nip: " + ip + " Mac: " + mac);
Log.d("IP : ", ip);
Log.d("Mac : ", mac);
}
}
Run the ip neigh show
command and process its output:
val runtime = Runtime.getRuntime()
val proc = runtime.exec("ip neigh show")
proc.waitFor()
val reader = BufferedReader(InputStreamReader(proc.inputStream))
You split the lines the same way, IP is [0], MAC is [4].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With