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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With