2010년 6월 25일 금요일

contacts photo 가져오기(주소록 사진)

주소록 사진 가져오기



retcursor = managedQuery(uri,projection,selection,orgSelection,sortOrder);

//getPhoto호출
long id = retcursor.getLong(retcursor.getColumnIndex(projection[0])); //projection[0] => ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
bitmap = getPhoto(resolver, id);

//비트맵으로 포토가져오기
public Bitmap getPhoto(ContentResolver contentResolver, Long contactId) {
Uri contactPhotoUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);

// contactPhotoUri --> content://com.android.contacts/contacts/1557

InputStream photoDataStream = Contacts.openContactPhotoInputStream(contentResolver,contactPhotoUri); // <-- always null
Bitmap photo = BitmapFactory.decodeStream(photoDataStream);
return photo;
}

//비트맵 넣기
ImageView contact_photo;
contact_photo=(ImageView) contact_infomation.findViewById(R.id.contact_photo);

contact_photo.setImageBitmap(photo);

댓글 없음: