我以与BasicSyncAdapter example相同的方式实施了同步任务,但在此答案中使用了Google帐户:
https://stackoverflow.com/a/2972918/2072569
除适用于Android 4.4.2和其他三星平板电脑的三星SM-P600(Galaxy Note 2014)外,它适用于所有设备 .
清单文件中的我的ContentProvider有一个标签 . 根据某些三星平板电脑的某些Android版本的this post,这就是这个错误的原因 .
Has Samsung blocked adding sync tasks to a Google account for some reason?
同步添加如下:
removeAllSyncTasks();
ContentResolver.setIsSyncable(mAccount, CONTENT_AUTHORITY, 1);
ContentResolver.setSyncAutomatically(mAccount, CONTENT_AUTHORITY, true);
ContentResolver.addPeriodicSync(mAccount, CONTENT_AUTHORITY, Bundle.EMPTY, SYNC_FREQUENCY);
清单部分:
<service
android:name=".data.sync.SyncService"
android:exported="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter"/>
</intent-filter>
<meta-data android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
<provider
android:name=".data.provider.LevensContentProvider"
android:authorities="@string/authority"
android:label="@string/app_name_sync"
android:exported="false"
android:syncable="true" />
Syncadapter xml:
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter
xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="@string/authority"
android:accountType="com.google"
android:userVisible="true"
android:supportsUploading="true"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"/>
当我手动启动同步时 . Syncservice也没有从三星平板电脑开始(它适用于所有其他设备) .
1 回答
事实证明它与三星/ OS版本无关......
我的SyncHelper的构造函数是:
这不会检查帐户类型 . 列表中有一个类型为com.evernote的帐户,这用于同步,而且当前的帐户不起作用 .
添加此解决方案:
现在我可以开始撞墙了;;-)