1

How to force data synchronization (calendar, contacts) from own program?

The internet connectivity is not stable, so when a WiFi connection occurs, I want to force the sync. I've googled sth about synchronization manager, but there is not much info how to use it.

deKayan
  • 31
  • 6
  • 1
    Stuff like that is implemented by the particular application. So unless each application has a way to tell it to sync data, I don't think there's much you can do. – Falmarri Nov 10 '10 at 18:51

2 Answers2

2

I got the answer:

Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, true);
context.getContentResolver().startSync(null, extras); 

tnx to Toby http://tobykurien.blogspot.com/2010/08/batteryfu-android-application.html?showComment=1289567283337#c6639350316170925780

deKayan
  • 31
  • 6
0

In order to know whether connectivity has changed, write a broadcast receiver of android.net.conn.CONNECTIVITY_CHANGE. And then ask for connection details to ConnectivityManager. If changed, synchronize.

This post is related.

Community
  • 1
  • 1
Martín Schonaker
  • 7,273
  • 4
  • 32
  • 55
  • 1
    OK that is clear. But, how can I force the sync of e.g. my google account when the broadcast receiver gets message when there is a connection estabilshed? – deKayan Nov 12 '10 at 12:55