Home android - Creating a service to listen UDP multicast in the background even when the screen is off?
Reply: 0

android - Creating a service to listen UDP multicast in the background even when the screen is off?

user1192
1#
user1192 Published in July 18, 2018, 6:26 am

I'm working on a Android application that needs to receive UDP multicast packets from the local Wi-Fi network continously in the background. The reason for using multicast is the sender don't know the IP address of the device, so the sender can only send a multicast to discover the device(the packets contains a identifier and the device will check it and send a reply packet). But I have to use a MulticastLock to receive packets and when the screen goes off I can got nothing but actually I need to wake the device up by some packets. :(

I found some ways that forces the phone to keep the device awake by a WakeLock and uses a MulticastLock, or even roots the device and modify the WiFi driver. But I think it may noticeablely shorten the battery life so I wonder if there is a better solution to listen the UDP packets? I just want to wake up the device when a certain type of packet from a specified multicast group is received.

or is there any other way to establish communication with the phone when the IP address is unknown? The application have a pairing function so if any other identifiers needed to be exchanged can be exchanged here.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.430424 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO