--- layout: post status: publish published: true title: Getting a custom Sync Service and Adapter to show up under "Data and Synchronization" on Android wordpress_id: 564 wordpress_url: http://www.martineve.com/?p=564 date: !binary |- MjAxMS0wMS0xNCAwODoxNDowOCArMDEwMA== date_gmt: !binary |- MjAxMS0wMS0xNCAwODoxNDowOCArMDEwMA== categories: - Technology - Android tags: - Android - Mendeley - synchronization - Java comments: [] ---

Androids!

As mentioned previously, the two part tutorial on c99.org is a great starting place for people wanting to write their own synchronization service for Android. The only problem is that, because it syncs to Contacts, it omits to tell you what to do to get your new service appearing under Settings -> Accounts -> "Data and Synchronization".

The answer is surprisingly simple, but also elusive. As the tutorial stated, you certainly need:

{% highlight xml %} {% endhighlight %}

This on its own, however, is not necessarily enough. It turns out that the check Android performs to ascertain whether to display a sync item underneath the "Data and Synchronization" panel is a call to ContentResolver.getIsSyncable(account), which has to return a positive integer value. This means that, in certain cases (of which I remain unsure), you'll need to call:

{% highlight java %} ContentResolver.setIsSyncable(account, "com.martineve.mendroid.data.mendeleycollectionsprovider", 1); {% endhighlight %}

... probably on some form of application startup/install.

If you need further guidance on this, I'd suggest browsing through my work at the Mendeley for Android Google Code repository.