Unregistering a zeroconf service using jmDNS
Question
I'm tryng to make my Android app register a service via zeroconf while the app is active, and then unregister it after the app exits. In my onResume method I have the following code:
// register ourselves with zero conf
try {
JmDNS jmdns = JmDNS.create();
serviceInfo = ServiceInfo.create("_http._tcp.local.", "My App Service", SERVER_PORT, 0, 0, false, "path=/crazycatapp");
jmdns.registerService(serviceInfo);
} catch (Throwable t) {
Debug.e("Error registering service with zeroconf", t);
}
and then subsequently in my onPause method:
if(serviceInfo != null) {
// unregister ourselves with zero conf
JmDNS jmdns = JmDNS.create();
jmdns.unregisterService(serviceInfo);
}
} catch (Throwable t) {
Debug.e("Error unregistering service with zeroconf", t);
}
I've elimintated the code that does multicast enabling, etc. The point is, I can register the service just fine, and can subsequently see it using a zeroconf browser on another device. However, once registered, the service never disappears unless I actually disable the wifi on the device that registered the service. The call to unregisterService doesn't seem to actually affect a service registration. unregisterAllServices doesn't seem to have any effect either. Anyone have any ideas?
No correct solution