plouh
plouh

Reputation: 2069

How to enable synchronization of custom account in android?

I am writing my own SyncAdapter for android devices that should synchronize TV broadcast information to the device but ran into problem of not getting the Synchronize "mydata" checkbox visible under Data & Synchronization part of the account preferences.

I have implemented my own SyncAdapter and defined it properly in the xml:

Here is my sync.xml:

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="com.example.tv.programs"
    android:accountType="com.example.tv.sync"
    android:supportsUploading="false"
    android:userVisible="true"
/>

Corresponding part of android manifest, where I define my sync service and provider:

<service android:name=".sync.ProgramSynchronizationService" android:exported="true" android:process=":programs">
    <intent-filter>
        <action android:name="android.content.SyncAdapter" />
    </intent-filter>
    <meta-data
        android:name="android.content.SyncAdapter"
        android:resource="@xml/sync" />
</service>

<provider android:name="com.example.tv.providers.ProgramContentProvider" 
    android:authorities="com.example.tv.programs" />

Am I doing something wrong as I don't get anything visible under the Data & Synchronization part?

Upvotes: 5

Views: 4264

Answers (2)

Chrispix
Chrispix

Reputation: 18261

To add to this, if you want to enable Syncing automatically you can do

ContentResolver.setSyncAutomatically(account, "com.example.tv.programs",true);

Upvotes: 3

Martin Eve
Martin Eve

Reputation: 2751

In addition to your sync-adapter setup, you also need to call (perhaps at program start):

ContentResolver.setIsSyncable(account, "com.example.tv.programs", 1)

Upvotes: 10

Related Questions