2014-09-19 57 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

相關問題