Jason Gooner
Jason Gooner

Reputation: 3281

How to edit accounts & sync settings for a specific account

Under the 'Accounts & Sync' settings graphical OS menu, there are listings of user-configured Google accounts.

Please could someone point me in the right direction to programmatically change the sync settings associated with one of these accounts?

Thanks

Upvotes: 3

Views: 6849

Answers (3)

kingston
kingston

Reputation: 11419

ContentResolver.setSyncAutomatically(account, authority, true/false): sets whether or not the provider is synced when it receives a network tickle.

Upvotes: 1

David Leonard
David Leonard

Reputation: 1748

Maybe ContentResolver#setIsSyncable() can do what you want.

Perhaps would be better to fire the android.provider.Settings.ACCOUNT_SYNC_SETTINGS intent with either the EXTRA_AUTHORITIES extra set to ["google.com"], or possibly put the extra named "account" as the Account object you got from AccountManager. Then your user can turn their sync on or off for themselves.

Upvotes: 1

Erich Douglass
Erich Douglass

Reputation: 51992

Those settings use the new AccountManager APIs. Here's some sample code that shows how to add a new account. I'd assume that you'd want to get the credentials of one of the existing accounts and simply modify the data.

Unfortunately, I haven't had a chance to try out those APIs yet.

Upvotes: 2

Related Questions