Reputation: 93
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?
Upvotes: 3
Views: 7516
Reputation: 17037
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! : )
Upvotes: 6
Reputation: 156
You can use Google Android NSD service.
Check out http://developer.android.com/training/connect-devices-wirelessly/nsd.html
Upvotes: 1
Reputation: 8978
Assuming that both devices are in the same local network you could use/write kind of ip scanner (Check every single ip adress whether is alive and if it is try to connect).
Upvotes: 0