0

We have a requirement to schedule periodic sync jobs for an Android Application. There is no hard schedule requirement but as long as the sync runs every 6-7 hours, it should be fine (provided there is network connectivity). We're using compileSdkVersion as 22 and minSdkVersion as 15(ICS). There are a couple of solutions I could find:

  • AlarmManager(does not consider network availability)
  • SyncAdapter(needs a sync account)
  • JobScheduler
  • GcmNetworkManager

Which of the above is the best candidate and why?

1 Answers1

1

I would recommend GcmNetworkManager as it can do exactly what you want. It will even persist a periodic task and resume them on boot.

  • AlarmManager - as you say, it does not consider network availability. Also, by using the GcmNetworkManager your app will have less effect on battery use as the task will usually be run when other tasks are running.
  • SyncAdapter - intended more for syncs based on a server push. It is used for syncing gmail and the Google Calendar apps for example, where a sync is triggered by the server when a change is made on the web client or another device.
  • JobScheduler - Would also be a good choice, but it's only available on Android L.
morepork
  • 973
  • 6
  • 9
  • It should be noticed that using `GcmNetworkManager` automatically means that you are using `JobScheduler` on `Android L+`. The API is defined that way. – Christopher Rucinski Sep 22 '15 at 16:06