Android jmDNS discovery

Asked by At

I am trying jmDNS service discovery for Android, but something is not going well. Trying to discover all the services active out there in my local network but can't.

Initialization is as below :

val wifi = context!!.applicationContext.getSystemService(android.content.Context.WIFI_SERVICE) as WifiManager
lock = wifi.createMulticastLock("IO_LOCK")
lock!!.setReferenceCounted(true)
lock!!.acquire()


val ipAddress = InetAddress.getByName("192.168.1.5") //local IP
val hostname = ipAddress.hostName
Log.e("IP ", ipAddress.hostAddress)
Log.e("HOSTNAME ", hostname)
jmdns = JmDNS.create(ipAddress, hostname)
jmdns!!.addServiceTypeListener(SampleTypeListener())
jmdns!!.addServiceListener("_http._tcp.local.", SampleListener())
jmdns!!.addServiceListener("_ftp._tcp.local.", SampleListener())
jmdns!!.addServiceListener("_ipp._tcp.local.", SampleListener())
jmdns!!.addServiceListener("_http._tcp.local.", SampleListener())
jmdns!!.addServiceListener("_services._dns-sd._udp.local.", SampleListener())

But it is not working... How to listen for all available active services in local betwork ?

I mean , how to find all active services like UPNP when sending M-SEARCH ?

0 Answers