5

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?

plouh
  • 2,029
  • 3
  • 15
  • 22

2 Answers2

10

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

ContentResolver.setIsSyncable(account, "com.example.tv.programs", 1)
Martin Eve
  • 2,703
  • 1
  • 23
  • 23
3

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

ContentResolver.setSyncAutomatically(account, "com.example.tv.programs",true);
Chrispix
  • 17,941
  • 20
  • 62
  • 70
  • The Android documentation suggests that doing this will cause syncing every few seconds. Please could you respond to this in my question: http://stackoverflow.com/questions/22206596/how-to-enable-sync-without-syncing-every-few-seconds ? – cja Mar 05 '14 at 19:10