ICS ContentResolver Sync Changes and Fix

Nowhere in the Android documentation could a fix be found for the issue we were encountering on Ice Cream Sandwhich, Android OS 4.0

We got feedback from a user saying upon the first login the app would not stop syncing, even after he let it sit for 30 minutes. However, Once the app was closed and re-opened it synced perfectly.

The app would hang here making the user think it just took forever to sync when in reality it was just hanging because the account did not have sync permission

 

We were able to narrow the problem down to the account not having the sync settings turned on even though in older versions of Android it worked properly.

Dialog when Sync button was pressed

The Account was added to the sync settings but not activated

The code we were using to start  the sync was simply

ContentResolver.setSyncAutomatically(application.getUserAccount(), MyStyleProvider.AUTHORITY, true);

This, strangely enough, worked fine on all Android Phones that did not have Ice Cream Sandwhich. We searched and searched but could not find an answer. We tried adding more permissions to no avail. The fix came on a whim when I saw there was a MasterSync property. I could not find any documentation to back that this needed to be true for ICS phones but setting it to true solved the issue and the sync works great!

ContentResolver.setMasterSyncAutomatically(true);

Tags: , ,

Leave a Reply