androidgoogle-cloud-messaginggcm-network-managergcmtaskservice

Android GCMNetworkManager - Running a job between a specific timeframe everyday


I want to be able to run a periodic task within a certain timeframe every day, for example, between 8 AM and 11 AM. I'm not sure how I can do this with PeriodicTask, because you cannot specify a specific time of day.

I stumbled across this example, but it uses Evernote's Android-Job library. Is there a way to achieve this with GCMNetworkManager specifically?


Solution

  • No, this is not possible with GCMNetworkManager.

    However, this level of time gating can be achieved with the Awareness API as of the February 2017 - v.10.2 by registering a TimeFence (more specifically, the inDailyInterval() method).