Communication between two Android phones using a Wi-Fi network

I want to communicate between two android phones, both phones are connected to the same wifi network. Knowing the IP address, I can use sockets directly to communicate with both devices, but my question is, is it possible to get the IP address at runtime? Or is there another way I can do this?

+3


source to share


3 answers


You can use jmDNS to achieve this. This is a really useful library, and once you find all devices connected to the same wifi, you can get their ip and port so you can establish a connection. You can read more on how to use it here .

Or you can use Android Wi-Fi Direct API which only works for API level 14+. Here's some more API information: Wifi-Direct .



Hope this is what you are looking for! :)

+6


source


You can use Google Android NSD service.



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

+1


source


Assuming both devices are on the same local network, you can use / record the ip scanner view (check each individual ip address if it is alive and if it tries to connect).

0


source







All Articles