简体   繁体   中英

Communication between two Android phones using Wi-Fi network

I want communication between two Android phones, both the phones are connected to the same Wi-Fi network. Knowing the IP address I can directly use sockets to communicate with both the devices, but my question is, is it possible to get the IP address at the run time? Or is there some other way in which I can do this?

You can use jmDNS to achieve this. It's a really helpful library and once you detect the all devices connected to the same wifi you can get their ip and port so you can establish a connection. You can learn more about how to use it here .

Or you can use Android Wi-Fi Direct API which works only for API Level 14+. Here is more information about the API : Wifi-Direct .

Hope it is what you are looking for! : )

You can use Google Android NSD service.

Check out http://developer.android.com/training/connect-devices-wirelessly/nsd.html

假设两个设备都在同一个本地网络中,你可以使用/写一种ip扫描器(检查每个ip地址是否存活以及是否尝试连接)。

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