0
Android 앱에서 작업 중입니다. 내 앱에서 연락처 표시 이름과 displaypic을 표시해야합니다. 숫자로 연락처 표시 이름을 가져 오는 경우 다음 코드를 사용하고 있습니다.연락처로 사진 찍기
public String getContactDisplayNameByNumber(String number) {
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
String name = " ";
ContentResolver contentResolver = getContentResolver();
Cursor contactLookup = contentResolver.query(uri, new String[] {BaseColumns._ID,
ContactsContract.PhoneLookup.DISPLAY_NAME }, null, null, null);
try {
if (contactLookup != null && contactLookup.getCount() > 0) {
contactLookup.moveToNext();
name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
//String contactId = contactLookup.getString(contactLookup.getColumnIndex(BaseColumns._ID));
}
} finally {
if (contactLookup != null) {
contactLookup.close();
}
}
return name;
}
잘 작동합니다. 연락해주세요. 이런 식으로 연락주세요.
이것은 아마도 http://stackoverflow.com/a/8695649/704374 – Akshay
@ Akshay..You 만 나는 그것을 확인하지 않은 이유 displayname..Thats에 대한 질문 right..But이다 중복. 도와 주셔서 감사합니다. 대답으로 게시하면 받아 들일 수 있습니다. :) – sarath