Code example for NsdServiceInfo

Methods: getServiceName, getServiceType

0
            } 
 
            @Override 
            public void onServiceFound(NsdServiceInfo serviceInfo) {
                logMsg("Service discovery found: " + serviceInfo);
                if (!serviceInfo.getServiceType().equals(SERVICE_TYPE)) {
                    logMsg("Unknown Service Type: " + serviceInfo.getServiceType());
                } else if (serviceInfo.getServiceName().equals(mServiceName)) {
                    logMsg("Same machine: " + mServiceName);
                } else if (serviceInfo.getServiceName().contains(mServiceName)) {
                    mNsdManager.resolveService(serviceInfo, mResolveListener);
                } 
            } 
 
            @Override 
            public void onServiceLost(NsdServiceInfo serviceInfo) {
                logMsg("service lost."); 
                if (serviceInfo == mService) {
                    mService = null;
                } 
            }