我正在尝试从 android 电话簿中导入联系人。该应用程序在所有手机上都能正常运行,但在 HTC 手机上失败。我的代码如下
Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
pickContactIntent.setType(Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers
startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST);
Uri contactUri = data.getData();
String[] projection = {Phone.DISPLAY_NAME,Phone.NUMBER};
Cursor cursor = getContentResolver()
.query(contactUri, projection, null, null, null);
cursor.moveToFirst();
// Retrieve the phone number from the NUMBER column
int column = cursor.getColumnIndex(Phone.NUMBER);
int nameColumn=cursor.getColumnIndex(Phone.DISPLAY_NAME);
String number = cursor.getString(column);
String fName=cursor.getString(nameColumn);
contact = new HashMap<String, String>();
contact.put(fName, number);
eName.setText(fName);
因为它是在客户端电话上,所以我无法查看日志。