Question

I'm trying to build a SyncAdapter that should be run every few seconds to quick check for specific data. I'm using following code to run SyncAdapter

ContentResolver.setIsSyncable(account, CONTENT_AUTHORITY, 1);           
ContentResolver.setSyncAutomatically(account, CONTENT_AUTHORITY, true);

and the sync is trigerred correclty however I noticed that it's call only once every ten minutes. Based on android training http://developer.android.com/training/sync-adapters/running-sync-adapter.html saying:

When a network connection is available, the Android system sends out a message every few seconds to keep the device's TCP/IP connection open. This message also goes to the ContentResolver of each app. By calling setSyncAutomatically(), you can run the sync adapter whenever the ContentResolver receives the message.

The network connection i available however it's only 3G connection, not WiFi - is this a reason on long wait? How can I make my adapter to run every 10 seconds? I already tried using periodic sync

ContentResolver.addPeriodicSync(account, CONTENT_AUTHORITY, new Bundle(), 10);

but it's still running every 10 minutes.

Was it helpful?

Solution

You are victim of the android SyncManager. Consider this scenario: you add a every 10 minutes sync for your application, but you have installed my application on your phone which as well asks the manager for a 10 minutes periodic sync and my application did the schedule requirement one second before than yours :) The sync operation of my application involves a transfer of big loads of data, hence using the whole ( or almost ) bandwidth of the available internet connection. The smart SyncManager will see that is not wise to start another sync process until the previous is done, and so it will wait the process to end, and only afterwards fire your sync.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top