2014-09-19 33 views
4

我目前正在开发一个聊天应用程序,我正在使用下面的Vcard来存储用户信息。如何将自定义字段添加到XMPP电子名片Android/SMACK

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

除了我想新的字段添加到虚拟卡像

vcard.setNotificationType(user.getNotType()) 
vcard.setAlerts(user.getAlerts()) 

上述值这可能吗?如果是这样,请帮助我如何做到这一点。 谢谢。

+1

请注意,您似乎想要在Vcard中存储配置首选项。 VCard意图是公开的并且可以被其他人检索。 – 2015-01-25 20:41:27

+0

只要我可以保存这些数据,这不是问题。可能吗? – Kishath 2015-01-26 06:14:17

+1

是的,这是可能的,但是您使用的功能与需要的功能非常不同。你为什么不使用XMPP私人存储? http://xmpp.org/extensions/xep-0049.html – 2015-01-27 13:50:27

回答

2

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

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

例如:

vcard.setField("NotificationType", user.getNotType()); 

而且把它找回来:

vcard.getField("NotificationType"); 
+0

非常感谢您的帮助。它效果不错:) – Kishath 2015-01-26 06:16:42

+0

很高兴我可以帮助^ _ ^ – 2015-01-26 10:06:29

相关问题