There are several choice for making a WiFi program in android, most common methods are using NSD and WifiP2pManager.
What is different between these 2 choice?
Firstly, these are not two entities to be differentiated. Even if you use Wi-Fi P2p for NSD, you should use WifiP2pManager for connection initiation and negotiation. NSD is to be used for Discovery phase
I assume your question to be difference between Using Wi-Fi P2p Service Discovery(NSD) and Not using it (using normal scan
The answer is explicitly provided here under the three sub-topics. However
The difference is actually in the initial phase: The peer discovery phase
In the case, where you need to discover only peers that are of your interest, then Wi-Fi P2p Service discovery should be used. Here, the filter condition is set in the name of Service.
For ex: your app "XYZ" needs to form groups ONLY with other devices that also uses the same app "XYZ", then you can create a service and name it, say
service_xyz, and this service info will be broadcast along with the Wi-Fi Direct device details. On the receiver end, you implement a service listener that listens for the service "service_xyz". By doing so, only devices with the desired service name are discovered and listed. Useful for gaming apps, social networking apps.
However, after this phase, in both the methods, from the discovered list a particular device is selected and connect request is initiated. From here on, the following phases are the same - connection request, negotiation, group formation...
hope this helped you.