From Android 4.1 (under Wi-Fi Direct service discovery) it is suppose to support native UPnP service discovery.
I presume it was developed for Wi-Fi Direct, but the methods available seem to be generic. Even the JavaDoc for methods mention that it searches for all UPnP services on the network and not only WiFi Direct slaves/masters.
However, I am failing to implement it so that it works... I manage to set up all requirements and I get positive onSuccess
callbacks, but I receive no onUpnpServiceAvailable
callbacks notifying about services on the network. I do have 3 services on UPnP which I can discover using 3rd-party library.
Has anyone tried this feature?
final Channel mChannel;
final WifiP2pManager mManager;
WifiP2pServiceRequest mRequester;
mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), new ChannelListener() {
public void onChannelDisconnected() {
Log.i("CI", "Channel detected!");
}
});
mManager.setUpnpServiceResponseListener(mChannel, new UpnpServiceResponseListener() {
public void onUpnpServiceAvailable(List<String> arg0, WifiP2pDevice arg1) {
Log.i("sd", "Found device!!");
}
});
mRequester = WifiP2pUpnpServiceRequest.newInstance();
mManager.addServiceRequest(mChannel, mRequester, new ActionListener() {
public void onSuccess() {
Log.i("d", "AddServiceRequest success!");
mManager.discoverServices(mChannel, new ActionListener() {
public void onSuccess() {
Log.i("d", "DiscoverServices success!");
}
public void onFailure(int reason) {
}
});
}
public void onFailure(int reason) {
}
});