有谁知道如何从电话簿获取email2和mobile2?对于email2和mobile2,BlackBerryContact类没有像BlackBerryContact.EMAIL这样的常量。
答案 0 :(得分:3)
if (contacts.isSupportedField(BlackBerryContact.EMAIL)) {
try {
if (contact.countValues(BlackBerryContact.EMAIL) > 0)
email1 = contact.getString(BlackBerryContact.EMAIL, 0);
System.out.println("Email1 " + email1);
if (contact.countValues(BlackBerryContact.EMAIL) > 1)
email2 = contact.getString(BlackBerryContact.EMAIL, 1);
System.out.println("Email2 " + email2);
} catch (Exception e) {
System.out.println("Exception::" + e.getMessage());
}
}
if (contacts.isSupportedField(BlackBerryContact.TEL)) {
int count = contact.countValues(BlackBerryContact.TEL);
for (int i = 0; i < count; i++) {
int attribute = contact.getAttributes(BlackBerryContact.TEL, i);
if(attribute == BlackBerryContact.ATTR_MOBILE){
String mobile = contact.getString(BlackBerryContact.TEL,i);
lblField1.setText(mobile);
}
if(attribute == BlackBerryContact.ATTR_HOME){
String home = contact.getString(BlackBerryContact.TEL, i);
lblField2.setText(home);
}
}
}