我想从 Android 联系人列表中获取数据。我得到了 display_name,但没有得到数字。我使用了这段代码:
while(people.moveToNext()){
try{
int nameFieldColumnIndex = people.getColumnIndex(Phone.DISPLAY_NAME);
String name = people.getString(nameFieldColumnIndex);
try{
int numberFieldColumnIndex = people.getColumnIndex(Phone.NORMALIZED_NUMBER);
String number = people.getString(numberFieldColumnIndex);
HashMap<String,String> contactMap=new HashMap<String, String>();
contactMap.put("name", name); // per la chiave image, inseriamo la risorsa dell immagine
contactMap.put("number",number); // per la chiave name,l'informazine sul nome
data.add(contactMap); //aggiungiamo la mappa di valori alla sorgente dati
}catch(IllegalStateException e){e.printStackTrace();}
我试过了:
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER};
Cursor people = getContentResolver().query(uri, projection, null, null, null);
但结果是一样的,我得到了显示的名称而不是数字。我读了一些有用的帖子,但我没有完成。建议?
提前致谢!