Android mDNS TXT Record

I am trying to access mDNS TXT record in Android application using Network Service Discovery APIs. Basically my application needs to open services and access the TXT record from them.

How to access mDNS TXT record from Android Network Service Discovery APIs. Whether there is support for accessing the TXT record from the network service discovery APIs.

+3


source to share


3 answers


Support for accessing TXT records was only added in API level 21 (Android 5.0) using the getAttributes () method in NsdServiceInfo .



If you need support for older Android versions, you will unfortunately need to use a library like jmDNS to access the TXT records.

+2


source


As mentioned in the comments, the NsdServiceInfo.getAttributes () method is a TXT record access, but the error means that the getAttributes () result is empty. This makes the Network Service Discovery API useless if you need a TXT record.



I want Google to fix this as it uses NsdManager compared to e.g. jmDNS seems to be much faster when looking for services. In the meantime, if it helps, I've devised a workaround to manually fetch the TXT record over the wire when NsdManager notifies a new service. It was open source as a library under the MIT license.

+2


source


My colleagues found a great library to work around this error, which uses the real Apple DNSSD Java API:

RxDNSSD

BonjourBrowser is a great example app that uses all the features on Android. It's also great for creating your own mDNS service for testing purposes.

I tried TinyDNSSD mentioned below by Steve Lilly but it didn't work for me because it doesn't work when your service doesn't have all the entries. When fe A-Record is missing, it doesn't work (TimeOutException).

0


source







All Articles