无法读取J2ME PIM联系人详细信息

时间:2011-12-26 17:16:56

标签: java-me contact pim

我想在诺基亚S60 sdk中使用PIM apis阅读联系方式,如姓名,姓名,手机号码,电话,传真,地址,同步和UID详细信息。

但是,我只获得Contact.TEL和Contact.EMAIL值,没有获得其他值,但是,我能够在模拟器联系人详细信息中看到其他字段,如名字,姓氏。

我已经配置了所有必需的权限。

ContactList addressbook = (ContactList) (PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.READ_ONLY));
Contact contact = null;

Enumeration items = addressbook.items();
while (items.hasMoreElements()) {
String name = "";
String telephone = "";
String mobile = "";
String email = "";
String InternetTelephone = "";
String Company = "";
String JobTitle = "";
String Synchronisation = "";
String UID = "";
String LastModified = "";
String contactRow = "";
System.out.println("\n *** NEW ITEM  ***");
contact = (Contact) (items.nextElement());
System.out.println(" * contact : " + contact.toString());
try {      
name = contact.getString(Contact.FORMATTED_NAME, 0);
System.out.println("Name = " + name);
} catch (Exception ex) {
 System.out.println(" Name  error "+ ex.getMessage());
}

try {       
mobile = contact.getString(Contact.ATTR_MOBILE, 0);
System.out.println("Name = " + name);
} catch (Exception ex) {
 System.out.println(" Name  error "+ ex.getMessage());
}


try
{   telephone = contact.getString(Contact.TEL, 0);
System.out.println("Telephone = " + contact.getString(115, 0)); //field 115: Telephone
} catch (Exception ex) {
System.out.println(" Telephone  error "+ ex.getMessage());
}

try
{      
email = contact.getString(Contact.EMAIL, 0);
System.out.println("E-mail = " + contact.getString(103, 0)); 
} catch (Exception ex) {
 System.out.println(" E-mail  error "+ ex.getMessage());
}

try
{ 
UID = contact.getString(Contact.UID, 0);
System.out.println(" UID " + UID ); 
} catch (Exception ex) {
System.out.println(" UID  error "+ ex.getMessage());
}

try
{
LastModified = contact.getString(114, 0);
System.out.println(" Last modified " + contact.getString(114, 0)); 
} catch (Exception ex) {
System.out.println(" Last modified error "+ ex.getMessage());
}

期待您的宝贵建议。

提前致谢。

1 个答案:

答案 0 :(得分:1)