Hi all!
This is my first post and i am pretty new to smack so i apologise if this issue is a schoolboy error on
my part.
basically, i want to add an avatar to a user’'s vCard so i tried:
URL urldefault=new URL(“http://www.bbc.co.uk/tv/d/images/thumbnails/hp_jeremy_clarkson.jpg”);
VCard vCard = new VCard();
vCard.setJabberId(UserName);
vCard.setAvatar(urldefault);
vCard.save(connection);
However this failed and spat out the error
java.lang.NullPointerException
at org.jivesoftware.smack.util.StringUtils.encodeBase64(StringUtils.java:293)
at org.jivesoftware.smack.util.StringUtils.encodeBase64(StringUtils.java:282)
at org.jivesoftware.smackx.packet.VCard.setAvatar(VCard.java:330)
Next, i tried the other approach suggested:
URL urldefault=new URL(“http://www.bbc.co.uk/tv/d/images/thumbnails/hp_jeremy_clarkson.jpg”);
byte[] avatar = VCard.getBytes(urldefault);
VCard vCard = new VCard();
vCard.setJabberId(UserName);
vCard.setAvatar(avatar);
vCard.save(connection);
This failed too and produced the same error as before. I have been hacking away at this
for ages now but keep stalling on the setAvatar() bit.
Any help would be greatly appreciated.
Thanks,
Steven