Search code examples
androidsdklockingmulticastlisten

Android SDK - is multicastlock working? it does not work when screen is off!


I implemented codes for receiving multicast diagram. My phone can get a diagram when screen is on.

However when screen is off, phone does not get any diagram from subnet. (PC sends a diagram on subnet for searching phone.) I though that multicast lock api(WifiManager.MulticastLock) can solve this problem, but it does not work.

How can I listen multicast diagram, phone screen is off ?


Solution

  • You will also need a WakeLock and perhaps also a regular WifiLock. WifiManager.MulticastLock will not keep the device powered on and may not keep the WiFi radio powered on.