Someone asking for a snippet of code for computing a Gmail acount
avatar. Since I'm not totally a bad person, here it is:
String gtalkAccount = "userName" + "@gmail.com";
String imFilter = Im.Contacts.USERNAME + "='" + gtalkAccount + "'";
Cursor imCursor = contentResolver.query(Im.Contacts.CONTENT_URI, null,
imFilter, null, null);
try
{
if (imCursor.first())
{
String avatarFilter = Im.Avatars.CONTACT + "='" + gtalkAccount +
"'";
Cursor avatarCursor =
contentResolver.query(Im.Avatars.CONTENT_URI, null, avatarFilter,
null, null);
String portraitData = null;
try
{
if (avatarCursor.first())
{
portraitData =
avatarCursor.getString(avatarCursor.getColumnIndex(Im.Avatars.DATA));
}
else
{
log.debug("No avatar found for the contact '" + gtalkAccount
+ "'");
}
}
finally
{
if (avatarCursor != null)
{
avatarCursor.close();
}
}
byte[] avatarBytes = Base64Utils.decodeBase64(portraitData);
// Taken from
http://groups.google.com/group/android-developers/browse_thread/thread/5146790eca08279e#
Bitmap portraitBitmap =
BitmapFactory.decodeByteArray(portraitBytes, 0, portraitBytes.length);
}
log.debug("Cannot find the contact in GTalk with resource '" +
peopleResource + "' and GTalk account '" + gtalkAccount + "'");
return null;
}
finally
{
if (imCursor != null)
{
imCursor.close();
}
}
Hope this helps...
Cheers,
Édouard
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---