Using AccountManager addAccountExplicitly takes a long time for the first synchronization

I am using AccountManager addAccountExplicitly () to add an account to AccountManager. Then i call

ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true); 

After that, looking at the “Accounts and sync” screen, I see my account, but when I click, I see that the “Sync contacts” checkbox is not displayed. It may take several minutes for it to appear ...

I found out that if I listen to the added account and after a delay (2 seconds) it rings:

 ContentResolver.requestSync(account, ContactsContract.AUTHORITY, new Bundle()); 

It is synchronized.

1. What does synchronization take time to synchronize? 2. Is this the right way to sync your account immediately? (will it always work?)

+4
source share
1 answer

I had a similar problem and the edited part of this answer helped me. The first synchronization lasts forever

At the first synchronization, call cancelSync and repeat the synchronization.

ContentResolver.cancelSync(account, authority);

0
source

All Articles