GcmTaskService vs SyncAdapter

I recently read about GcmTaskService and GcmNetworkManager for task scheduling. In my case, the typical SyncAdapter is used, where I need to periodically synchronize some data with my server, and currently I'm using SyncAdapter. My question is what are the differences between GcmTaskService and SyncAdapter. And when to use the GcmTaskService and when to use the SyncAdapter?

+7
android google-cloud-messaging android-syncadapter
source share
1 answer

GcmTaskService : Implemented by the client application to provide an endpoint for the GcmNetworkManager to return to when the task is ready to be completed. Tasks should be scheduled based on the execution window in time. During this run window, the scheduler will use its discretion to select the optimal run time based on network availability, network activity, and load.

The synchronization adapter synchronizes data between the server and the local database. Synchronization adapters run asynchronously; they transmit data regularly and efficiently, but not instantly. If you need real-time data transfer, you should do it in AsyncTask or IntentService. This structure helps manage and automate data transfer and coordinate synchronization operations across applications.

Google Cloud Messaging (GCM) provides both the server and the devices needed to run this messaging system. Using GCM to initiate transmissions is more reliable and more efficient than polling server for status. During polling, a Service that is always active is required; GCM uses the BroadcastReceiver, which is activated when a message arrives. While polling at regular intervals uses battery power, even if updates are not available, GCM sends messages only when necessary.

-2
source share

All Articles