尝试从联系人选择器中检索返回的结果时出现此错误。
10-18 09:03:14.704: ERROR/AndroidRuntime(14003):
Caused by: java.lang.RuntimeException:
Failure delivering result ResultInfo {
who=null,
request=1001,
result=-1,
data=Intent {
dat=content://com.android.contacts/data/42 flg=0x1 (has extras)
}
}
to activity {
com.fttech/com.fttech.EditCreate
}:
java.lang.NullPointerException
以下是我检索结果并返回所选联系人的方式。它只对某些联系人这样做。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case (CONTACT_PICKER_RESULT):
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor contact = managedQuery(contactData, null, null, null, null);
if (contact.moveToFirst()) {
number = contact.getString(contact.getColumnIndexOrThrow(Phone.NUMBER));
if(currentNumber.isEmpty()){
numbers.setText(number);
}else{
numbers.setText(currentNumber +","+number);
}
}
}
break;
}//getContactInfo
我如何修复此问题或以防御方式对此进行编码?