Tuesday, January 11, 2011

Re: [android-developers] Re: Accessing Facebook photos from the Contacts provider

i think you can get the FB photo by use the this code

public static Bitmap getContactPhoto(Context context, long photoId,int
defaultIco) {
Cursor photoCursor = null;
Bitmap photoBm = null;

try {
photoCursor = context.getContentResolver().query(
ContentUris.withAppendedId(Data.CONTENT_URI, photoId),
new String[] { Photo.PHOTO },
null, null, null);

if (photoCursor.moveToFirst() && !photoCursor.isNull(0)) {
byte[] photoData = photoCursor.getBlob(0);
photoBm = BitmapFactory.decodeByteArray(photoData, 0,
photoData.length);
}
} finally {
if (photoCursor != null) {
photoCursor.close();
}
}
if (photoBm == null)
return BitmapFactory.decodeResource(context.getResources(), defaultIco);
else
return photoBm;
}

于 11-1-12 上午4:21, Biosopher 写道:
> That's right, appel. I'm trying to access the FB contacts through the
> ContactsContract. Seems like the Facebook photos are stored with
> special permissions.
>
> I can get an FB photo's row _id from the Photos db but cannot retrieve
> the photo for some reason.
>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate