어이 모든 내 애플 리케이션에 표시하려면 내 전화 이미지를 얻는 데 문제가 프로그래머 thats있어. 다음 코드는 그가 연락처 사진 얻기 위해 사용하는 것입니다 :안드로이드 연락처 전화 이미지
private long getContactIdFromNumber(String number) {
Cursor c = null;
try {
String[] projection = new String[] { Contacts.Phones.PERSON_ID };
Uri contactUri = Uri.withAppendedPath(
Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));
c = getContentResolver().query(contactUri, projection, null, null,
null);
if (c.moveToFirst()) {
long contactId = c.getLong(c
.getColumnIndex(Contacts.Phones.PERSON_ID));
return contactId;
}
} finally {
c.close();
}
return -1;
}
private boolean initPhoto() {
boolean result = true;
try {
contactPhoto = People.loadContactPhoto(getApplicationContext(),
ContentUris.withAppendedId(People.CONTENT_URI,
getContactIdFromNumber(phoneNumber)),
R.drawable.header, null);
} catch (Exception e) {
result = false;
}
return result;
}
if (initPhoto()) {
contact1.setImageBitmap(contactPhoto);
contact2.setImageBitmap(contactPhoto);
contact3.setImageBitmap(contactPhoto);
}
내 전화 번호와 이미지와의 접촉을 만들었을하지만 결코 응용 프로그램에서로드하지 않습니다. 그가 올바른 전화 번호를 잡기 위해 위에 게시 한 코드에서 무엇을 찾고 있어야합니까?
그래서 내가 그 연락처의 이름을 보내면 그 연락처에 대해 어떤 이미지가 있는지 알 것입니다. – StealthRT