So I just got an Incredible and am writing an app that accesses
contact photos (2.2 api right now). So on my device, I installed the
facebook app, had to go into the People app, go to the Online
Directories tab, then tap Facebook. Had to re-enter my FB login info.
At that point, it downloaded all my FB contacts and linked them to my
phone entries.
The interesting point is that my app is getting the FB photos!
However, my brother has a moto Droid-X, and my app isn't getting the
photos on his device. Don't know if this is because of moto blur
wierdness, but it works on my HTC, and not on his Moto.
Anyone have any ideas why this would be? My function for retrieving
the bitmaps is below, the stuff I added at the bottom is stuff I added
for playing with alternate means of grabbing the photos, but it's
getting them using the standard part at the top.
Any input appreciated,
Dean
public static Bitmap loadContactPhoto(Context context, long id) {
ContentResolver cr = context.getContentResolver();
Uri uri =
ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
InputStream input =
ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
if (input != null) {
return BitmapFactory.decodeStream(input);
}
// didn't find the image from standard means,
Cursor cursor = null;
int photoRow = -1;
byte raw_photo[] = null;
try {
String where = ContactsContract.Data.RAW_CONTACT_ID + " = " +
id + " AND " +
ContactsContract.Data.MIMETYPE + "=='" +
ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE +
"'";
cursor = cr.query(ContactsContract.Data.CONTENT_URI, null,
where, null, null);
int idIdx =
cursor.getColumnIndexOrThrow(ContactsContract.Data._ID);
Boolean bResult = cursor.moveToFirst();
while (bResult && raw_photo == null) {
photoRow = cursor.getInt(idIdx);
raw_photo =
cursor.getBlob(cursor.getColumnIndexOrThrow(ContactsContract.Data.DATA15));
bResult = cursor.moveToNext();
}
} catch (Exception e) {
//Log.e(DEBUG_TAG, "Failed to get email data", e);
} finally {
if (cursor != null) {
cursor.close();
}
}
if (raw_photo != null) {
return BitmapFactory.decodeByteArray(raw_photo, 0,
raw_photo.length);
}
return null;
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en