Search code examples
androidandroid-wifiwifi-direct

How can I Listen for the event of a connection to my AP?


I create a WI-FI AP with my phone(Phone A), then enable it successfully; then I use another phone(Phone B) to connect to the AP;

Now I want to know how I can get info of devices that are connecting to the AP created by Phone A;

It's better that I can listen for the event of a connection to the AP.

Who can help me ? or there're suggestions ?


Solution

  • It seems no open APIs to do so. Here is a workaround, keep an eye on the file: /proc/net/arp You can test with this command: adb shell cat /proc/net/arp To get some result like this:

    IP address       HW type     Flags       HW address            Mask     Device
    192.168.43.83    0x1         0x2         80:c6:ab:4b:e9:4d     *        wlan0
    

    This is the list of your DHCP clients that connected to your portable AP.