I'm currently working on a SyncAdapter to add contacts from a WebService. Everything is working fine on the emulator but Contacts doesn't show up on my HTC Desire running HTC Sense.

I've read that Sense needs "real" contacts to "link" the new one but I'm pretty sure Facebook sync application adds new contacts.

So does anyone know how it can be done? Thanks.

有帮助吗?

解决方案

Ok, just got it working, you just have to declare your account in the groups. Here is what I've done :

ContentProviderClient client = mContext.getContentResolver().acquireContentProviderClient(ContactsContract.AUTHORITY_URI);
ContentValues cv = new ContentValues();
cv.put(Groups.ACCOUNT_NAME, account.name);
cv.put(Groups.ACCOUNT_TYPE, account.type);
cv.put(Settings.UNGROUPED_VISIBLE, true);
client.insert(Settings.CONTENT_URI.buildUpon()
    .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
    .build(), cv);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top