Pergunta

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.

Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top