Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Sync Adapter - manual Sync

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);

enter image description here

like image 663
Blindsurfer Avatar asked Jul 11 '26 08:07

Blindsurfer


1 Answers

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);
like image 53
avmatte Avatar answered Jul 13 '26 21:07

avmatte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!