如何将自定义字段放入 XMPP vCard Android/SMACK

Kis*_*ath 5 android xmpp vcf-vcard smack

我目前正在开发一个聊天应用程序,我正在使用以下 Vcard 来存储用户信息。

public void run() {
VCard vcard = new VCard();
vcard.setJabberId(xmppConnection.getUser());
vcard.setNickName(user.getChatId());
vcard.setFirstName(user.getUsername());
vcard.setPhoneHome("CELL", user.getMobileNo()); }
Run Code Online (Sandbox Code Playgroud)

除了上述值,我想向 Vcard 添加新字段,例如

vcard.setNotificationType(user.getNotType())
vcard.setAlerts(user.getAlerts())
Run Code Online (Sandbox Code Playgroud)

这可能吗?如果是这样,请帮助我如何做。谢谢。

Muh*_*raf 4

我知道这是一个老问题,但也许有人需要答案..

您可以使用vCard.setField(String field, String value)

例如 :

vcard.setField("NotificationType", user.getNotType());
Run Code Online (Sandbox Code Playgroud)

并把它拿回来:

vcard.getField("NotificationType");
Run Code Online (Sandbox Code Playgroud)