仍然面临在Android 2.3中加载实际联系人照片的问题。* ...尝试了很多不同的方法,但无法从电话簿中获取最新照片。我的上一个代码:
Uri uri = getPhotoUri(context, contact.getPhoneBookContactId());
Picasso.with(context).load(uri).error( R.drawable.contact_icon ).into(imageViewLowGB);
其中getPhotoUri:
public static Uri getPhotoUri(Context context,final int contactId) {
try {
Cursor cur = context.getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
null,
ContactsContract.Data.CONTACT_ID + "=" + contactId + " AND "
+ ContactsContract.Data.MIMETYPE + "='"
+ ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE + "'", null,
null);
if (cur != null) {
if (!cur.moveToFirst()) {
return null; // no photo
}
} else {
return null; // error in cursor process
}
} catch (Exception e) {
Log.e( ImageManager.class.getSimpleName(), "error getPhotoUri" +e.getMessage() );
return null;
}
Uri person = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI,contactId );
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
}
此代码可以给我照片,但如果更改照片,旧照片会一次又一次地加载(( 请有人帮帮我......这个问题仅限2.3。*版本(