私は編集テキストとボタンがあります。編集テキストでは数字を入力し、ボタンを押すと連絡先情報が表示されるか、連絡先の名前が返されます。番号から連絡先の名前を取得
私は運がないあらゆる種類の方法を試しました。私が成功裏に成功したのは以下のものでした...しかし、私はその名前を返す運がなかった。説明するように最適化されたPhoneLookupプロバイダを使用する必要があることについては
Cursor phoneCursor = null;
contactList = new HashMap<String,String>();
try{
Uri uContactsUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String strProjection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME;
phoneCursor = getContentResolver().query(uContactsUri, null, null, null, strProjection);
phoneCursor.moveToFirst();
String name = "";
String phoneNumber = "";
int nameColumn = phoneCursor.getColumnIndex(Phone.DISPLAY_NAME);
int phoneColumn = phoneCursor.getColumnIndex(Phone.NUMBER);
phoneCursor.moveToNext();
}
}
catch(Exception e){
Log.e("[SmsMain] getContactData", e.toString());
}
finally{
if(phoneCursor != null){
phoneCursor.close();
phoneCursor = null;
}
}
}