From Android 4.1 (when opening the Wi-Fi Direct service), it is supposed to support native detection of the UPnP service.
I assume it was designed for Wi-Fi Direct, but the methods available seem to be common. Even the JavaDoc for methods mentions that it searches for all UPnP services on the network, not just Wi-Fi virtual slaves / masters.
However, I donโt execute it to make it work ... I manage to configure all the requirements and I receive positive onSuccess , but I do not receive onUpnpServiceAvailable notifying about network services. I have 3 services on UPnP that I can detect using a third-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) { } });
source share