我想从android中的电话簿过滤同步的facebook联系人,是否有任何投影内容:// scheme,用于检索内容。
这是我当前查询给定的URI,将光标返回到结果集。
public static Cursor getContactList(ContentResolver cr) {
// reading all data in descending order according to DATE
Cursor curContact = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
return curContact;
}
是的...您可以根据帐户类型获得同步的联系人。对于WhatsApp,它是“com.whatsapp”(* facebook的帐户类型尚未测试)。所以只需定义帐户类型,如下例所示
Cursor c = getContentResolver().query(
RawContacts.CONTENT_URI,
new String[] { RawContacts.CONTACT_ID, RawContacts.DISPLAY_NAME_PRIMARY },
RawContacts.ACCOUNT_TYPE + "= ?",
new String[] { "com.whatsapp","facebook" },
null);
ArrayList<String> myWhatsappContacts = new ArrayList<String>();
int contactNameColumn = c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY);
while (c.moveToNext())
{
// You can also read RawContacts.CONTACT_ID to read the
// ContactsContract.Contacts table or any of the other related ones.
myWhatsappContacts.add(c.getString(contactNameColumn));
}