Printer Discovery from Android Device

This time I will show you how to discover Printers over a wifi network, to do this we need to use the jmDNS Java Library which is an implementation of Multi-Cats DNS, a network service discovery service.

First of all we need to create a Printer Object which is here:

This class represents an instance of a Printer in the Local Network.

Then we need to implement the ServiceListener, here it is for you:

We instantiate it on our main activity

And finally we start it and stop it onResume and onPause respectively:

We should see on the Log something like this:

Remember to add this permissions in your manifest:

<uses-permission android:name=”android.permission.INTERNET”/>
<uses-permission android:name=”android.permission.ACCESS_WIFI_STATE” />
<uses-permission android:name=”android.permission.CHANGE_WIFI_MULTICAST_STATE” />

Leave a Reply