jMdns and Android 4.0
I wanted to post a quick note just in case anyone else runs into this issue or I forget it later on.
jMdns is a great java library to provide zeroconf/bonjour capabilities to your Android application. I was successfully using this in a project up until Android 4.0 “Ice Cream Sandwich” aka ICS, once Android 4.0 devices were starting to be used more often I was receiving user reports that the application was not working. I knew it was a jmdns issue, I just didn’t have an ICS device to be able to track down the issue.
Well I was at Google I/O this year and picked up a few Jelly Bean (Android 4.1) devices. Both of these devices have the same issue that was being reported by Android 4.0 devices, basically the zeroconf functionality was not working.
It took me quite a while to track down but I figured out the problem.
Most jmdns Android tutorials instruct you to create your jmdns object by calling “jmdn.create();”. This works fin in Android 2.x and 3.x, but does not always work with Android 4.x
To fix the issue use the “jmdns.create(String Hostname);” constructor passing in the ip address of your wifi connection which can be obtained from a WifiInfo object from the Android WifiManager service.
Hopefully this helps people in the future, it seems something changed between Android 2.x/3.x and Android 4.x where the default jmdns.create() function is no longer bound to the regular wifi interface.