Android NSD not discovering all services

后端 未结 6 622
慢半拍i
慢半拍i 2021-02-02 08:24

I\'m trying to run an application using Android Native Service Discovery but sometimes when I run the application, it doesn\'t discover all services from my network. I\'m runnin

6条回答
  •  滥情空心
    2021-02-02 08:45

    I tend to think the whole NSD implementation in Android must be a bit flaky. I also have a simple Activity just to demonstrate the lifecycle (no Sockets are opened), and sometimes it works, and sometimes it does not work. I simply don't get it. Here is the Activity if anybody has some insight:

    https://github.com/mholzel/Dump/blob/master/NetworkServiceDiscoveryViaWifi.java

    On the other hand, Wifi Direct based NSD seems to be very reliable for me:

    https://github.com/mholzel/Dump/blob/master/NetworkServiceDiscoveryViaWifiDirect.java

    Note that neither of these Activities have any resources, so just add the Activities to your Manifest with the proper permissions.

提交回复
热议问题