I'm working on a project to send free calls over wi-fi. I'm using Node.js on the back end with sockets to send the voice. And I want to "notify" the user on real time when he has an incoming call from my service. It is very important to be on real time. Otherwise the user won't know when he is receiving a call.
I want to imitate the same behavior an incoming call has on android. That means I want to wake the device and send it to my android activity every time it receives a call.
I don't know how to implement this feature. Should I create a service that uses a socket to listen my server always?, Or should I create a "alarm" to check every 5 seconds or so?. Or a totally different solution?
I don't want to consume too many resources from the device. Hope I was clear enough. Please ask If you need any clarification of the project.
You can use Google Cloud Messaging to wake up your connection with the server. A service always can be closed by the SO. An Activiy and activity connection always can be closed by the SO and an alarm can consume a lot of memory.