【发布时间】:2014-09-05 23:48:30
【问题描述】:
我想检索 whatsapp 上的联系人电话号码。 我能够读取联系人的姓名,但无法获取电话号码。 这是我的代码
void readwhatsapp()
{
StringBuffer output = new StringBuffer();
ContentResolver cr1 = getContentResolver();
Cursor c = cr1.query(
RawContacts.CONTENT_URI,
new String[] { RawContacts.CONTACT_ID, RawContacts.DISPLAY_NAME_PRIMARY,RawContacts.PHONETIC_NAME },
RawContacts.ACCOUNT_TYPE + "= ?",
new String[] { "com.whatsapp" },
null);
int contactNameColumn = c.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY);
int contactIDColumn = c.getColumnIndex(RawContacts.CONTACT_ID);
while (c.moveToNext())
{
// You can also read RawContacts.CONTACT_ID to read the
// ContactsContract.Contacts table or any of the other related ones.
output.append(c.getString(contactNameColumn));
output.append(" ");
//getContactAccount(c.getString(contactIDColumn),cr1);
}
outputText.setText(output);
}
【问题讨论】: