Code example for NsdManager

Methods: registerService

0
     * Register service to mDNS/DNS-SD. 
     */ 
    void registerService() { 
        NsdServiceInfo serviceInfo = allocateServiceInfo();
        int protocolType = NsdManager.PROTOCOL_DNS_SD;
        nsdManager.registerService(serviceInfo, protocolType, registrationListener);
    } 
 
    /** 
     * Unregister service from mDNS/DNS-SD. 
     */ 
    void unregisterService() { 
        if (regstrationListenerRegistered)
            nsdManager.unregisterService(registrationListener);
    } 
 
    // Activity's lifecycle methods. 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);