Code example for NsdManager

Methods: resolveService

                    // The name of the service tells the user what they'd be 
                    // connecting to. It could be "Bob's Chat App". 
                    Log.d(TAG, "Same machine: " + mServiceName);
                } else if (service.getServiceName().contains(SERVICE_NAME)) {
                    mNsdManager.resolveService(service, mResolveListener);
            public void onServiceLost(NsdServiceInfo service) {
                // When the network service is no longer available. 
                // Internal bookkeeping code goes here. 
                Log.e(TAG, "service lost" + service);
            public void onDiscoveryStopped(String serviceType) {
                Log.i(TAG, "Discovery stopped: " + serviceType);
            public void onStartDiscoveryFailed(String serviceType, int errorCode) {
Connect your IDE to all the code out there  Get Codota for Java