How can I discover zeroconf (Bonjour) services on Android? I’m having trouble with jmDNS

I’m new as well otherwise I would have just left a comment on smountcastle’s answer which is mostly correct. I have just been dealing with the exact same issue on a Droid running Android 2.1. I found that I needed to set the MulticastLock to reference-counted otherwise it seemed to be released automatically.

AndroidManifest.xml:
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

// Networking code:
WifiManager wifi = getSystemService( Context.WIFI_SERVICE );
MulticastLock lock = wifi.createMulticastLock("fliing_lock");
lock.setReferenceCounted(true);
lock.acquire();

Just make sure to call lock.release() when you’re done with it. This may only be necessary for Android 2.0+, The Droid is my only test device currently, so I can’t say for sure.

Leave a Comment