Java – How to debug (test) GcmNetworkManager?

How to debug (test) GcmNetworkManager?… here is a solution to the problem.

How to debug (test) GcmNetworkManager?

In After this question I decided to use the alternative, after some research I found out GcmNetworkManager from 2.1 Backwards compatible and everything is fine, if I change the time the device the alarm will be triggered, the question is:

How do I do this using GcmNetworkManager?
I want to be able to force the execution of a scheduled task.

Any ideas?
Thank you.

Solution

You can run debugging tasks from the command line. Check javadoc on the The end of the GcmNetworkManager class

There is currently no way to trigger the execution of tasks scheduled by your app. Exposing command-line tools that allow you to trigger tasks on GcmTaskService for arbitrary packages is a security issue.

However, as mentioned in the document above, you can run it

adb shell dumpsys activity service GcmService --endpoints MyGcmTaskService

Find out what the network administrator has prepared for your service, whether it is ready, how many times the label has been executed since its launch, etc.

Related Problems and Solutions