我将创建一个无服务器的本地网络应用程序的iOS和Android。该应用程序在iOS和Android设备应该找出并互相交谈。
我知道,有平台的内置服务(这是卓悦在iOS和NSD在Android的自V4.1),此外,一个开源的 jmdns 包可以使用出框为好。
我不知道如何选择,如何为他们的兼容性。
我公司开发类似的项目。让我来回答你的问题:
是。 官方样片code 应该能够让你快速上手。实现服务发现的功能是很容易的。只有两个步骤:建立一个监听发现与有关回调,并作出单一的异步API调用来discoverServices()。 如果您使用的第三方库,优势:它可以使下面的Android 4.1应用程序工作; 缺点:发展服务发现会更复杂的功能。由于需要写入后台服务收听到网络上的广播。I will create a server-less local networking App for iOS and Android. the App in both iOS and Android devices should find out and talk to each other.
I know that there are platform built-in services (which are Bonjour in iOS and NSD in Android since v4.1), in addition, a open source jmdns package can be used out of the box as well.
I don't know how to choose and how is their compatibility.
解决方案
I developed similar project. Let me answer your questions:
Yes. The official sample code should be able to make your quick start. Implement the function of service discovery is very easy. Only two steps: setting up a discovery listener with the relevant callbacks, and making a single asynchronous API call to discoverServices(). If you use the third-party library, Advantage: It can make your application works below Android 4.1;Disadvantage: Developing the function of service discovery would more complex. Because of you need write a background service to listen to broadcasts on the network.