1

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

mobile app Beginner
  • 1,651
  • 3
  • 26
  • 40
  • Have you tried http://stackoverflow.com/a/9310388/194894 ? – Flow Mar 07 '12 at 18:11
  • Thanks Flow, I have tried to run 'configure(ProviderManager.getInstance());' before connecting to server. But it has the same result. Moreover, sometime I get the error message - 'Timeout getting VCard information: request-timeout(408) Timeout getting VCard information'. Do you have any idea? – mobile app Beginner Mar 08 '12 at 02:24
  • 2
    Problem solved by setting longer timeout. SmackConfiguration.setPacketReplyTimeout(30000); – mobile app Beginner Mar 16 '12 at 16:04
  • @mobileappBeginner I am not able to get proper VCard response can you let me know what you had done for getting the avtar for the user? – Lalit Poptani Mar 21 '12 at 17:46
  • 1
    http://code.google.com/p/parrot-im/source/browse/trunk/ParrotIM/src/controller/services/GoogleTalkManager.java?spec=svn2394&r=2394 - Please see getAvatarPicture() for how to get the avatar – mobile app Beginner Mar 22 '12 at 01:27
  • how are you saving the vcard? – Farhan Oct 30 '16 at 10:38

0 Answers0