-1

I am using AccountPicker to add a Google account in my device. Once it is added, I want to disable the syncing through code. I am able to stop contacts syncing for that account using the following code.

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

Now I want to disable mail syncing also. What Authority I should use to disable mail syncing through code? Or is there a way to disable complete account sync?

Vivek
  • 1,823
  • 1
  • 19
  • 39

2 Answers2

0

Edit :

Email is not part of the SDK. The sync is controlled via the mail app internally. The email provider itself is not exposed and is not available from outside the package to control its settings.

I took a look at the AOSP and the exchange app in it - They control the sync in the same way using the email authority. The authority for exchange is "com.android.email.provider"

RocketRandom
  • 1,102
  • 7
  • 20
  • setMasterSyncAutomatically() will disable sync for all accounts. I want to disable syncing for a particular account. I could not find Email authority in Android. – Vivek Apr 24 '15 at 09:18
0

I am able to solve it by getting the syncadapter types from ContentResolver and using their authority to disable sync for an account.

Example:

SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypes();

for(SyncAdapterType syncAdapterType : syncAdapters) {
    ContentResolver.setSyncAutomatically(account, syncAdapterType.authority, false);
}

It disables the sync for an account. Is this the right way?

Vivek
  • 1,823
  • 1
  • 19
  • 39