我实现了一个在Moto G上工作正常的简单syncadapter,但在Nexus 7上没有(onPerformSync永远不会被调用)
为了测试我手动启动同步:
Bundle settingsBundle = new Bundle();
settingsBundle.putBoolean(
ContentResolver.SYNC_EXTRAS_MANUAL, true);
settingsBundle.putBoolean(
ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
/*
* Request the sync for the default account, authority, and
* manual sync settings
*/
ContentResolver.requestSync(mAccount, DbContract.AUTHORITY, settingsBundle);
我的manifest.xml看起来像这样:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.com.jeldrik.teacherslittlehelper" >
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:authorities="app.com.jeldrik.teacherslittlehelper.data"
android:name="app.com.jeldrik.teacherslittlehelper.data.ClassContentProvider">
</provider>
<service
android:name="app.com.jeldrik.teacherslittlehelper.DataTransfer.AuthenticatorService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name="app.com.jeldrik.teacherslittlehelper.DataTransfer.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>
</application>
答案 0 :(得分:2)
嗯,简单的解决方案的愚蠢错误: Android正在发出警告,我的平板电脑内存几乎已满。 在这种情况下似乎所有同步都会自动停用。 删除了一些东西,现在同步工作:P