我遇到了此聯繫人檢索代碼的問題。函數getContact()將重新調用null。在j2me中檢索聯繫人時出現空指針異常
private PIM pim;
private ContactList clist;
public ContactExtract(){
pim=PIM.getInstance();
try{
clist=(ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY);
}catch(Exception e){}
}
public Vector getContact(){
//ContactDetail cd[]= new ContactDetail[200];
Vector v=new Vector();
try{
Enumeration en=clist.items();
//String num=null;
//String temp[]=new String[2];
//int i=0;
while(en.hasMoreElements()){
Contact c=(Contact)en.nextElement();
v.addElement(c);
//temp=c.getStringArray(Contact.NAME, i);
//num=c.getString(Contact.TEL, i);
//cd[i]=new ContactDetail(temp[0],temp[1],num);
}
clist.close();
}catch(Exception e){}
return v;