Felix
Felix

Reputation: 89626

What if I do not want to sync contacts?

In an Android app I'm working on, I'm using the AccountManager to store the user's account info and also sync a couple of sources (I have two services that respond to the android.content.SyncAdapter intent action).

However, I am not syncing contacts. In spite of this, if I go in the contacts app and choose to add a contact, I get a popup asking me under which account should the contact be created. The account created by my app is listed there as well. I have tried putting android:supportsUploading="false" on my <sync-adapter>s, doesn't work.

The only solution I currently see is to create an empty, invisible contact sync service that has android:supportsUploading="false", but that seems like the biggest and most useless hack ever.

Help?

Upvotes: 1

Views: 804

Answers (2)

rAm
rAm

Reputation: 79

if you do not want to sync contacts change the authority of your syncadapter's xml file to the authority of your apps contact provider . If you are not maintaining a contacts provider for your app. Just make a dummy provider and gives its authority to your sync adapter's xml file. Giving authority as com.android.contacts in your syncadapter's xml file will cause this behavior as you mentioned :

"However, I am not syncing contacts. In spite of this, if I go in the contacts app and choose to add a contact, I get a popup asking me under which account should the contact be created. The account created by my app is listed there as well. I have tried putting android:supportsUploading="false" on my s, doesn't work."

doing this will solve this issue

Upvotes: 0

Timothy Johns
Timothy Johns

Reputation: 1095

It appears to me that you have to specify both android:supportsUploading="false" AND your content authority must be android:contentAuthority="com.android.contacts" (ContactsContract.AUTHORITY).

See com.android.contacts.model.Sources.queryAccounts(), which fills in the .readOnly flag, and com.android.contacts.model.Sources.getAccounts(), which is used by com.android.contacts.util.AccountSelectionUtil.getSelectAccountDialog() to populate the contacts dialog.

What's not clear to me is whether this has additional (potentially undesirable) side effects -- particularly given that you're specifying a contentAuthority that is conceptually the opposite of what you want.

-Tim

Upvotes: 2

Related Questions