import org.jivesoftware.smack.util.StringUtils;//引入包
XMPPConnection con;
byte[] bytes;
con = XmppUtils.getInstance().getConnection();
VCard vCard = new VCard();
vCard.load(con, ConfigEntity.uname + "@192.168.1.66");
bytes = LiaoYiLiaoMyInfo.readByte(ConfigEntity.userHeadImg);
String encodedImage = StringUtils.encodeBase64(bytes);
v.setAvatar(bytes, encodedImage);
v.setEncodedImage(encodedImage);
v.setField("PHOTO", "<TYPE>image/jpg</TYPE><BINVAL>" +
encodedImage
+ "</BINVAL>", true);
v.save(con);
本文介绍如何使用Java通过XMPP协议更新用户的VCard资料中的头像信息,包括读取本地图片文件并将其编码为Base64字符串,然后通过XMPPConnection将更新后的头像保存到服务器。
1117

被折叠的 条评论
为什么被折叠?



