本文介绍了Asmack没有加载电子名片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是二进制版本Asmack的(我会尽快打造它,因为我有一段时间,因为我有问题,我第一次尝试)。我还建立了自己的ejabberd服务器。

I am using a binary release of Asmack (I will be building it as soon as I have some time as I had problems the first time I tried). I also set up my own ejabberd server.

当我尝试加载一些接触电子名片服务器返回的信息,但Asmack似乎不喜欢它(或无法解析)。

When I try to load some contact VCard the server returns the info but Asmack does not seem to like it (or fail to parse it).

这是我可以在调试模式下看看:

This is what I can see in debug mode:

<iq from='user@domain' to='admin@domain/Smack' id='I17sI-4' type='result'>
<vCard xmlns='vcard-temp' prodid='-//HandGen//NONSGML vGen v1.0//EN' version='2.0'>
    <FN>Full Name</FN>
    <N>
        <FAMILY>Surname</FAMILY>
        <GIVEN>Nick</GIVEN>
    </N>
    <NICKNAME>Nickname</NICKNAME>
    <URL>http://google.com</URL>
    <ADR>
        <LOCALITY>lanta</LOCALITY>
        <REGION>krabi</REGION>
        <PCODE>81150</PCODE>
        <CTRY>thailand</CTRY>
    </ADR>
    <EMAIL>
        <USERID>[email protected]</USERID>
    </EMAIL>
</vCard>
</iq>

但是当我做

VCard card = new VCard();
card.load(xmppConn, "user@domain");

所有的信息被设置为null,当我试图通过调用VCard.toXML()方法来看看XML我刚刚得到一个像这样的空XML

All the info is set to null, and when I try to look at the XML by calling VCard.toXML() method I just got an empty XML like this

<iq id="I17sI-4" to="user@domain" type="get"><vCard xmlns='vcard-temp'/></iq>

因此​​,任何人知道我做错了,或者这个二进制版本失败解析电子名片从服务器接收?

So anyone knows what I am doing wrong or if this binary release that fails to parse the VCard received from the server?

推荐答案

添加一行: ProviderManager.getInstance()addIQProvider(电子名片,名片 - 温度,新VCardProvider()); 加载名片了。

Add line: ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider()); before loading vCard.

这篇关于Asmack没有加载电子名片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 11:28