i'm trying to create a Sync Adapter for hours now.
The Sync-Setting is always deactivated. Why?
AndroidManifest
<provider
android:name="com.example.authenticating.DataProvider"
android:authorities="@string/content_authority"
android:exported="false"
android:multiprocess="true"
android:syncable="true" />
<service
android:name="com.example.authenticating.AuthenticatationService"
android:exported="true"
android:process=":auth">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
syncadapter.xml
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="@string/content_authority"
android:accountType="@string/sync_account_type"
android:userVisible="false"
android:supportsUploading="false"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true" />
Adding the Adapter
Account account = new Account(getString(R.string.sync_account_name), getString(R.string.sync_sync_account_type_name));
ContentResolver.setIsSyncable(account, getString(R.string.content_authority), 1);
accountManager.addAccountExplicitly(account, "", null);

If you want to perform a manual sync you have to call:
Bundle settings = new Bundle();
settings.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
settings.putBooleanContentResolver.SYNC_EXTRAS_EXPEDITED, true);
ContentResolver.requestSync(mAccount, AUTHORITY, settingsBundle);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With