Android Multicast socket stops listening

后端 未结 2 620
我在风中等你
我在风中等你 2021-01-20 09:59

I have a service on Android that listens and responds to packets it receives via multicast.

This works most of the time, but unfortunately, I\'m finding that every n

2条回答
  •  时光说笑
    2021-01-20 11:00

    Are you acquiring a multicast lock?

    WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    MulticastLock lock = manager.createMulticastLock("lock name");
    lock.setReferenceCounted(true);
    lock.acquire();
    

    It also seems like certain devices block multicast:

    Multicast on Android 2.2

提交回复
热议问题