문제

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