Code example for NsdManager

Methods: discoverServices

0
 
    @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() {
 
            public void onServiceRegistered(NsdServiceInfo NsdServiceInfo) {
                // Save the service name. Android may have changed it in order 
                // to 
                // resolve a conflict, so update the name you initially 
                // requested 
                // with the name Android actually used. 
                mServiceName = NsdServiceInfo.getServiceName();