public synchronized void start() { if (!started) { ARSALPrint.v(TAG, "Starting MdsnSd based ARDiscovery"); if (!multicastLock.isHeld()) { multicastLock.acquire(); } // this is sticky intent, receiver will be called asap context.registerReceiver(networkStateIntentReceiver, networkStateChangedFilter); started = true; } }
public synchronized void stop() { if (started) { ARSALPrint.v(TAG, "Stopping MdsnSd based ARDiscovery"); started = false; if (multicastLock.isHeld()) { multicastLock.release(); } context.unregisterReceiver(networkStateIntentReceiver); mdnsSd.stop(); netDeviceServicesHmap.clear(); broadcaster.broadcastDeviceServiceArrayUpdated(); } }