Code example for NsdServiceInfo

Methods: getServiceNamegetServiceType

            public void onServiceFound(NsdServiceInfo service) {
                // A service was found! Do something with it. 
                Log.d(TAG, "Service discovery success" + service);
                if (!service.getServiceType().equals(SERVICE_TYPE)) {
                    // Service type is the string containing the protocol and 
                    // transport layer for this service. 
                            "Unknown Service Type: " + service.getServiceType());
                } else if (service.getServiceName().equals(mServiceName)) {
                    // 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);
Contextual code suggestions in your IDE  Get Codota for Java