当前位置: 首页 > 工具软件 > JmDNS > 使用案例 >

android dns-sd,GitHub - orenk86/AndroidDnssdDemo: Example use of Dnssd discovery on Android (using j...

徐俊人
2023-12-01

AndroidDnssdDiscoveryEclipse: an eclipse version.

AndroidDnssdDiscovery: a netbeans version of the thing.

Below, how I got the AndroidDnssdDiscoveryEclipse project and how to run it.

* create an android project

* in the AndroidManifest.mf, add:

* after downloading jmdns 3.4.0, I needed to remove duplicate .class inside (at the same time I dropped the test classes):

** run: cp -r ~/jmdns.jar ./

** run: mkdir unjar

** run: cd unjar

** run: jar xf ../jmdns.jar

** run: jar cfm ../jmdns.jar META-INF/MANIFEST.MF javax/

** (create a copy or link for eclipse), run: cd ../AndroidDnssdDiscoveryEclipse && ln -s ../jmdns.jar

* refresh the project in eclipse

* add the jar as a dependency in eclipse by (right click on jmdns.jar and "build path -> add to build path"

* add info in the res/layout/main.xml:

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="" />

* fill the activity

* In eclipse, "run as -> android application"

** if you have a linux pc connected to same network, you should see it listed by your android phone within a few seconds (as it exposes a "_workstation._tcp" service)

** you should also see the service exposed by the phone using "avahi-browse --all" (the service is called AndroidTest)

== OLD VERSION BELOW (before I found the problem with jmdns)

* create an android project

* in the AndroidManifest.mf, add:

* after downloading jmdns 3.4.0 and finding no way to make dex compile the jar, I added the sources with:

** run: cp -r ~/app/jmdns-3.4.0/src/javax/ AndroidDnssdDiscoveryEclipse/src/

** run: rm -rf AndroidDnssdDiscoveryEclipse/src/javax/jmdns/test/

** refresh in eclipse

* add info in the res/layout/main.xml:

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="" />

* fill the activity

* In eclipse, "run as -> android application"

** if you have a linux pc connected to same network, you should see it listed by your android phone within a few seconds (as it exposes a "_workstation._tcp" service)

** you should also see the service exposed by the phone using "avahi-browse --all" (the service is called AndroidTest)

 类似资料: