I want to send a heartbeat from my application to the GCM server, so the connection will stay alive.
How can I do that, and how can I know the URL of my GCM server??
Thanks in advance!!
I want to send a heartbeat from my application to the GCM server, so the connection will stay alive.
How can I do that, and how can I know the URL of my GCM server??
Thanks in advance!!
Copyright © 2021 Jogjafile Inc.
How to send the heartbeat
This class can sent the proper intents
if you just want to send the heartbeat you can do the following in an Activity
I don't think you need to set any additional permissions for this but here are the gcm related permissions I have in my manifest
One way to send the heartbeats on a regular basis
If you want to send them on a regular basis, here is how I am doing that:
I also have a service that has an Dagger injected alarmmanger and pendingintent
Here is the section of the Dagger module that provides the alarm manager and pending intent. There are several ways to have an alarm manager periodically call a method, so assuming you don't use Dagger, you should still be able to pull out the relevant parts. Your question was how to send the heartbeat, not how to use an alarm manager. There are lots of answers to that already so search on that.