6
votes

I am implementing a messaging application with the XMPP protocol and Openfire server on android platform. I need save and load my own Vcard and other users vcard. At the moment, I managed to keep my vCard on the server and can load it again. The problem is with the other users Vcards, server always return XMPPError: feature-not-implemented - cancel.

I use this libraries:

compile 'org.igniterealtime.smack:smack-android:4.1.2-SNAPSHOT'
compile 'org.igniterealtime.smack:smack-tcp:4.1.2-SNAPSHOT'
compile 'org.igniterealtime.smack:smack-extensions:4.1.2-SNAPSHOT'

Show the code:

Save my own Vcard (Work fine).

VCardManager vCardManager = VCardManager.getInstanceFor(connection);
VCard vCard;
vCard = vCardManager.loadVCard();
vCard.setNickName("User name");
URL urldefault = new URL("Avatar URL");
InputStream stream = urldefault.openStream();
byte[] avatar1 = readBytes(stream);
vCard.setAvatar(avatar1, "avatar1/jpg");
vCard.setEmailHome("user email");
vCard.setPhoneHome("mobile", "888888888");
vCardManager.saveVCard(vCard);

Load my own Vcard (Work fine)

VCard vCard = null;
VCardManager vCardManager = VCardManager.getInstanceFor(connection);
vCard = vCardManager.loadVCard();

The problem is here. Load other user Vcard:

VCardManager vCardManager = VCardManager.getInstanceFor(connection);
boolean isSupported = vCardManager.isSupported(user);
if (isSupported)  // return true
    vCard = vCardManager.loadVCard(user);

The user name to load Vcard is correct.

Any ideas?

Thanks in advance.

1
hope You are seeing this, it´s an older post, but I got exactly the same problem. But the jid I try to load is [email protected], without the Smack extension. Have You any kind of idea why it doesn´t work?Opiatefuchs
mmm I resolved my problem with the jid of the user without the /Smack. What version you are using in your application?Alejandro Martínez Martínez
thanks for reply...I am using Smack 4.1.6 API, But yesterday I read some bug reports and seems that it is server dependant. My jid is proper, so that could not be the problem. One more question, Your connection, are You just logged in with Your jid or do I need to do some changes on Connection before calling the vcard of another user?Opiatefuchs
Not is neccesary to make any more changes. I logging with my JID and from there I can consult other users vCard. However, my experience with the use of vCard is that they are a bit unstable. If only you use to manage the avatar can work well, if you enter a lot of information the result is worse.Alejandro Martínez Martínez
Strange....ok, but again, many thanks for your reply.....Opiatefuchs

1 Answers

8
votes

The issue you might be facing is the suffix for the JID. The connection.getUser() method returns the JID as [email protected]/Smack. To get the vCard details, you need to query it as [email protected] (without the /Smack). Try that out and let me know if it works.