/** Register a DNS-SD service (to be discoverable through Bonjour/Avahi). */ protected void announceService() { nsdRegistrationListener = new NsdManager.RegistrationListener() { @Override public void onServiceRegistered(NsdServiceInfo serviceInfo) { logger.debug("onServiceRegistered()"); } @Override public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode) { logger.debug("onRegistrationFailed()"); } @Override public void onServiceUnregistered(NsdServiceInfo serviceInfo) { logger.debug("onServiceUnregistered()"); } @Override public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) { logger.debug("onUnregistrationFailed()"); } }; NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setServiceName("primitive ftpd"); serviceInfo.setServiceType("_" + getServiceName() + "._tcp."); serviceInfo.setPort(getPort()); NsdManager nsdManager = (NsdManager) getSystemService(Context.NSD_SERVICE); nsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, nsdRegistrationListener); }
public void registerService(int port) { NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setPort(port); serviceInfo.setServiceName(mServiceName); serviceInfo.setServiceType(SERVICE_TYPE); mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener); }
public void registerService(int port) { NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setPort(port); serviceInfo.setServiceName(mServiceName); serviceInfo.setServiceType(SERVICE_TYPE); mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener); System.out.println( TAG + " Registered " + String.valueOf(serviceInfo.getHost()) + " " + serviceInfo.getPort()); }
public void tearDown() { mNsdManager.unregisterService(mRegistrationListener); mNsdManager.stopServiceDiscovery(mDiscoveryListener); }
public void stopDiscovery() { mNsdManager.stopServiceDiscovery(mDiscoveryListener); discovering = false; }
public void discoverServices() { mNsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener); }
protected void unannounceService() { NsdManager nsdManager = (NsdManager) getSystemService(Context.NSD_SERVICE); nsdManager.unregisterService(nsdRegistrationListener); }
public void tearDown() { mNsdManager.unregisterService(mRegistrationListener); }