Search code examples
network-programmingipdevice-discovery

How to scan for wifi devices connected to the same wifi along with their names in Android 10?


I want to discover my PC's IP from my Android Phone and connect to a local server running at a particular port. Used the Fing tool and it shows the device name and their IP addresses.

image form the fing tool

How do I implement this in Android 10 and above? Since arp scanning is no longer allowed by Android 10. I tried ip neigh show but it returns an empty string.

  val runtime = Runtime.getRuntime()
        val proc = runtime.exec("ip neigh show")
        proc.waitFor()
        val reader = BufferedReader(InputStreamReader(proc.inputStream))
        val array = reader.lines().toArray()

Is this a good approach or should i host the server on my phone and scan my phone from PC?


Solution

  • Android API 30 or higher curtails the "ip" command, unfortunately, also in the name of protecting MAC addresses