[aerogear-dev] Comparing sync in Android vs other platforms

Summers Pittman supittma at redhat.com
Mon Mar 3 10:17:03 EST 2014


For the DevNexus Android app[1] I used Android native sync APIs[2] + the 
sync strawman[3] I put out back in December.  It worked surprisingly 
well with a few caveats.

First a background on how Android sync works.

Android sync is handled by three components: a SyncAdapter, a 
ContentProvider, and a Authenticator.

The Sync Adapter performs as sync and returns a status object.  The 
SyncAdapter is called from, managed by, etc the Android platform. It 
provides an onPerformSync that the developer implements.  In the 
application the developer sends signals to Android which control 
scheduling sync (periodic, immediate, event based etc).  Also Android 
will put in the "Account" settings page a control for the SyncAdapter.  
In this case the SQLSynchronizer I proposed was used to implement this 
method.

The ContentProvider is responsible for CRUD operations on your data, 
exposing your data to other apps on the device, and notifying the system 
if data changes.  This is managed by Android as well.  In this case the 
CP was backed by a SQLStore.

Finally the Android Authenticator is responsible for establishing and 
maintaining authentication with remote services.  If the user is not 
signed in, or if fetching an auth token fails, the Authenticator will be 
called by Android to provide a Activity which can be used to refresh the 
users account.  In this case I used two custom AuthenticationModules.  
One handled SSO with Google and the other handled keeping the cookie up 
to date.  Both communicated with the DevNexus server to keep all of the 
tokens fresh.

Overall, Android provides a very VERY slick (but very very complicated) 
way of managing sync AND keeping the sync state visible to the user.  If 
you use Androids APIs then the OS handles things like Authentication 
errors, intermittent connectivity, etc while providing configuration for 
a variety of sync use cases (UI event based, polling, data listening, etc).

I tried looking up what options are available in JS land but the closest 
I came to was a FFOS blurb about it is a TODO item and isn't a W3C 
proposal or anything yet.

I tried looking at iOS but the docs made my eyes cross.

So what does the PLATFORM support look like in these environments?

----
[1]https://github.com/secondsun/devnexusAndroid
[2]http://developer.android.com/training/sync-adapters/index.html
[3]https://github.com/secondsun/aerogear-android/tree/sync_strawman/src/org/jboss/aerogear/android/sync


More information about the aerogear-dev mailing list