Code example for NsdServiceInfo

Methods: getServiceName, getServiceType

1
            } 
 
            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. 
                    Log.d(TAG,
                            "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);
                } 
            } 
 
            public void onServiceLost(NsdServiceInfo service) {