
Add some init code to the bottom of the Activity's onCreate() method. Private static final String SERVICE_TYPE = "_workstation._tcp." Ĥ.B. The NSD service type that the RPi exposes.

Private NsdManager.ResolveListener mResolveListener Private NsdManager.DiscoveryListener mDiscoveryListener This allows the app to discover the garagedoor.local Network Service Discovery related members I added this to my MainActivity but my app is small and so that's all I needed to do. (2) I probably need to do something related to NSD in the Application lifecycle events of onPause(), onResume(), onDestroy() and onTeardown(). (1) Below is just how I decided to implement it, you may want to separate the NSD related code out of the Activity into its own class, but for me that wasn't a problem.
Bonjour browser linux android#
Source code changes needed in the Android App to support NSD (Network Service Discovery) In my case, I am using a custom app I wrote to communicate to the Raspberry Pi, so I have decided just to use the Network Service Discovery library.Ĥ. Using NSD (Network Service Discovery) on Android to resolve the Raspberry Pi's service name.īrowsers and terminal programs on Android won't be able to resolve the garagedoor.local since to do this requires use of either the official Network Service Discovery library (supported by API Level 16 up) or the open source Java Zeroconf library named jMDNS. On Linux, first ensure you have installed the avahi-daemon package.ģ. In a bash terminal window, type the command ping garagedoor.local - you should get a response from your Raspberry Pi. On Mac OSX, Bonjour Networking Services are installed by default. Run a cmd.exe prompt and type the command ping garagedoor.local - you should get a response from your Raspberry Pi. On Windows, you will need to have Bonjour Networking Services installed, which comes bundled with iTunes.
Bonjour browser linux mac osx#
Test on either Windows, Linux or Mac OSX that the Raspberry Pi is visible on the network with its new name of "garagedoor.local". That's the end of the changes needed on your Raspberry Pi.Ģ.

Bonjour browser linux install#
# Install the mDNS implementation - avahi Sudo /etc/init.d/hostname.sh # Commit the changes. Sudo nano /etc/hostname # <= Replace raspberrypi with garagedoor Sudo nano /etc/hosts # <= Replace raspberrypi with garagedoor # Change the host name of your Raspberry Pi from "raspberrypi" to "garagedoor" It turns out that the way to do this isn't difficult on the Raspberry Pi and most of work is in changes to the Android App needed to make it happen. I have written an Android app that communicates to my Raspberry Pi over SSH (using JSch) but the issue is that in the App the IP address of my Raspberry Pi has been hardcoded at 192.168.1.109 - ideally it would be good to be able to give it a local name, something like garagedoor.local - something that won't change when the DHCP assigns a different IP address.
