Search code examples
androidwifiandroid-wifip2p

App that will communicate between devices connected on the same local network Wi-Fi


So there's a requirement for an app that will communicate between devices if and only if its connected to the same local network.

E.G: Device A and Device B are connected to Wi-Fi network Z. The app will allow both the Devices to communicate between eachother (send messages/videos)

I've been researching the past couple of days but unable to get clarity with what I've found so far. (I'm confused between NSDManager, WifiP2pManager, etc. as to which one suits my requirement).

I just need confirmation between which concept/methodology to follow. Please help.


Solution

  • From my personal experience, WiFiP2PManager should do what you want. I have used it to connect two devices over the same WiFi network. It also allows your device to view all the other devices on the network and enables you to connect to them. Once you have connected to the device, you can then send messages across the WiFi network. This documentation does a good job of explaining how to use WiFi P2P and how to get started.

    It also explains how to view devices on the network, how to connect with them, and how to transfer data. This should suit the requirements that you requested.

    You can use NSD, but according to the documentation that is mainly used for giving your app access to services provided from other devices on the local network. It would allow your app to do file sharing with the other device by requesting a service.

    After searching it up, I have concluded that WiFi Direct is the same as WiFi P2P. They both use the WiFiP2PManager.Here is a link for information about it.