I am developing an Instant Messager in Android with smack 3.2.1 When I was trying to get the user avatar. I found that the Vcard not contains all the information that I can see in the XML.
Here is my code snippet:
// From other post - add vCard with addIQProvider before connect to server
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider());
connection = new XMPPConnection(config);
connection.connect();
...
VCard card = new VCard();
try
{
card.load(connection, "test@abc.com");
Log.e(TAG, card.toString());
/* return: <vCard xmlns='vcard-temp'><FN></FN></vCard>*/
Log.e(TAG, card.getAvatarHash());
/* exception - java.lang.NullPointerException: println needs a message */
}
catch(Exception e)
{
Log.e(TAG, "in exception");
Log.e(TAG, e.toString());
}
Presence presence = roster.getPresence("test@abc.com");
Log.e(TAG, presence.toXML());
/* return: <presence to="peter@abc.com/Smack" from="test@abc.com/3e34cf2b"><show>xa</show>
<x xmlns="vcard-temp:x:update">
<photo>5455bf2f365065ffb59da7414ac9f83cbc850ef2</photo>
</x><c xmlns="http://jabber.org/protocol/caps"></c></presence> */
Obviously, the presence.toXML() has the avatar information.
(1) I added 'ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider());' But why I still cannot access it by vCard? I have searched many posts, still cannot find solution.
(2) Is it any example of getting user avatar with smack/asmack?
Thanks