Download Vcards with Smack (Android) in Openfire Server

I am using an XMPP messaging application and an Openfire server on the Android platform. I need to save and load my own Vcard and other vcard users. At the moment, I managed to save vCard on the server and load it again. The problem with other Vcards users, the server always returns an XMPPError: the function is not implemented - will cancel.

I use these 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 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); 

Download my own Vcard (work fine)

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

The problem is here. Download another custom Vcard:

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

The correct username to download is Vcard.

Any ideas?

Thanks in advance.

+5
source share
1 answer

The problem you may encounter is the suffix for JID. The connection.getUser () method returns the JID as user@example.com / Smack. To get vCard data, you need to request it as user@example.com (without / Smack). Try this and let me know if that works.

+7
source

All Articles