Android application Wi-Fi device - AP connectivity

后端 未结 3 1835
Happy的楠姐
Happy的楠姐 2020-12-04 11:49

I am building an application which can transfer data between a mobile and a Wi-Fi device... The mobile has got the AP enabled (through code) and another device connects to t

3条回答
  •  佛祖请我去吃肉
    2020-12-04 12:21

    You could ping the device if you know its host-name or its IP address.

        Runtime runtime = Runtime.getRuntime();
        Process proc = runtime.exec("ping -c 1   " + hostname);
        proc.waitFor();
    

    You could do an IP address scan, trying every IP address on the network for a response using a ping like above or trying to connect using TCP or UDP.

    If you know the MAC address, you could use the ARP table.

    If you got some own software running on the devices, you could send out UDP packets on every device and listen for them on your Android device. See Sending and receiving UDP broadcast packets in Android on how to do this.

提交回复
热议问题