Code example for NsdServiceInfo

Methods: getHostgetPortgetServiceNamegetServiceType

            public void onServiceFound(NsdServiceInfo service) {
                Log.d(TAG, "Service discovery success");
                Log.d(TAG, String.format("%s %s %s %d",
                        service.getServiceName(), service.getServiceType(),
                        service.getHost(), service.getPort()));
                if (!service.getServiceType().contains(SERVICE_TYPE)) {
                            "Unknown Service Type: " + service.getServiceType());
                } else if (service.getServiceName().equals(mServiceName)) {
                    Log.d(TAG, "Same machine: " + mServiceName);
                } else { 
                    mNsdManager.resolveService(service, mResolveListener);
            public void onServiceLost(NsdServiceInfo service) {
                Log.e(TAG, "service lost" + service);
Connect your IDE to all the code out there  Get Codota for Java