Get profile image from google talk with asmack in android

android, asmack, avatar, smack

Solution

You can use `VCard` to load the details of any user using asmack,

Get Profile Image from google talk?

VCard vCard = new VCard();
SmackConfiguration.setPacketReplyTimeout(300000);
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp",
                    new VCardProvider());
vCard.load(connection, user_mail_id);
Log.d("Vcard XML", vCard.toXML()); // complete VCard information
byte[] bs = vCard.getAvatar();   // Avtar in byte array convert it to Bitmap

How do i get userid in asmack?

You have to iterate through the Roster Entries to get user_mail_id,

Roster roster = connection.getRoster();
Collection<RosterEntry> rosterEntries = roster.getEntries();

for (RosterEntry entry : rosterEntries) {
   String user_mail_id = entry.getUser();
}

Problem

I use asmack to connect with google talk (Android). I can get name, email. I looked this link. It uses `"http://profiles.google.com/s2/photos/profile/" + userid + "?sz=" + size;` for google talk image profile. How do i get userid in `asmack`? Or any other ways can i do to get profile image of google talk?

Original source