我正在开发一个android应用程序。我想从联系人中提取信息(例如家中或办公室的辅助电话号码)。有什么建议么?如何在android中加载辅助联系人?
1
A
回答
1
你需要运行于所有手机查询..
Cursor phones = cr.query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + id, null, null);
try {
phones.moveToFirst();
while (!phones.isAfterLast()) {
ContactPhone phone = new ContactPhone();
String number = phones.getString(phones.getColumnIndex(Phone.NUMBER));
// 0 = false | 1 = true
int primary = phones.getInt(phones.getColumnIndex(Phone.IS_PRIMARY));
int type = phones.getInt(phones.getColumnIndex(Phone.TYPE));
//Do whatever you want with this info
phones.moveToNext();
}
} finally {
if (phones != null) {
phones.close();
}
}
0
这是很难知道你做了什么,到目前为止,因为你没有张贴任何代码无论如何,但我前人的精力建议你检查此链接:
http://developer.android.com/reference/android/provider/ContactsContract.Data.html
这一个:
http://developer.android.com/reference/android/provider/ContactsContract.DataColumns.html#MIMETYPE
嗨Rafeel如何获得第二个电话号码,这意味着工作电话号码或其他 – Krishna 2011-04-06 23:45:46
运行此查询您正在获取联系人的所有电话。 “type”字段保留Phone类型的值......您可以比较它以获得正确的类型,如下所示: 'if(type == Phone.TYPE_WORK){ //它是一部工作电话 } else if(type == Phone.TYPE_MOBILE){ //手机.. }' – Panthro 2011-04-07 13:57:16
感谢真正有用的感谢简要解释 – Krishna 2011-04-09 00:14:57