Code example for NsdManager

Methods: registerService

0
        // with other services advertised on the same network. 
        serviceInfo.setServiceName(SERVICE_NAME);
        serviceInfo.setServiceType(SERVICE_TYPE);
        serviceInfo.setPort(port);
 
        mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD,
                mRegistrationListener);
    } 
 
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public void discoverService() { 
        bDiscoverying = true;
        initializeDiscoveryListener(); 
        mNsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD,
                mDiscoveryListener);
 
    } 
 
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public void initializeRegistrationListener() { 
        mRegistrationListener = new NsdManager.RegistrationListener() {