5

我正在为应该将电视广播信息同步到设备的 android 设备编写自己的 SyncAdapter,但遇到了在帐户首选项的数据和同步部分下没有显示同步“mydata”复选框的问题。

我已经实现了自己的 SyncAdapter 并在 xml 中正确定义了它:

这是我的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"
/>

android manifest 的相应部分,我在其中定义了我的同步服务和提供者:

<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" />

我做错了什么,因为我在数据和同步部分看不到任何东西吗?

4

2 回答 2

10

除了同步适配器设置之外,您还需要调用(可能在程序启动时):

ContentResolver.setIsSyncable(account, "com.example.tv.programs", 1)
于 2011-01-14T07:55:57.017 回答
3

要添加到这一点,如果您想自动启用同步,您可以执行

ContentResolver.setSyncAutomatically(account, "com.example.tv.programs",true);
于 2012-01-31T22:11:51.380 回答