Changing nickname

Hi there.

I’ve got a problem with Smack. Is there a way to change my nickname? Now all my roster entries see me as "mymail@gmail.com" and I want them to see “My Name”. When I add a user to the roster I can also specify a desirable nickname but how can I change my own?

Thank you in advance,

astrognom

You can change your own VCard with org.jivesoftware.smackx.packet.VCard

Hi, Op3rational

and thaks for the imediate reply. I tried:

VCard vCard = new VCard();

vCard.setNickName(“MyName”);

xmppConn.sendPacket(vCard);

But I cannot my friends don’t see any update in my info.

You really need to consult the API documentation, often there are examples.

VCard (Smack 3.0.4 Documentation)

Usage:

// To save VCard:

VCard vCard = new VCard();

vCard.setFirstName(“kir”);

vCard.setLastName(“max”);

vCard.setEmailHome(“foo@fee.bar”);

vCard.setJabberId("jabber@id.org");

vCard.setOrganization(“Jetbrains, s.r.o”);

vCard.setNickName(“KIR”);

vCard.setField(“TITLE”, “Mr”);

vCard.setAddressFieldHome(“STREET”, “Some street”);

vCard.setAddressFieldWork(“CTRY”, “US”);

vCard.setPhoneWork(“FAX”, “3443233”);

vCard.save(connection);

// To load VCard:

VCard vCard = new VCard();

vCard.load(conn); // load own VCard

vCard.load(conn, “joe@foo.bar”); // load someone’s VCard

You also should load your VCard first, so that the other values remain intact.

Ok, I tried this:

VCard vCard = new VCard();

try {

vCard.load(xmppConn);

vCard.setNickName(“MyNickname”);

vCard.save(xmppConn);

} catch (XMPPException e) {}

and next time I do:

VCard vCard = new VCard();

vCard.load(this);

I get: “No VCard for yourUser@gmail.com

I get the same thing for an user that has set his VCard through Pidgin when calling:

VCard vCard = new VCard();

vCard.load(xmppConn, "someUser@gmail.com");

Edit: in doLoad(XmppConncention connection, String user) the PacketCollector receives only PacketReaders but no VCards, and I’m sure the user has one.

change “this” to your “xmppConn” object. Note that this call only loads your own VCard.

astrognom wrote:
I get: “No VCard for yourUser@gmail.com

I get the same thing for an user that has set his VCard through Pidgin when calling:

bq. VCard vCard = new VCard();

bq. vCard.load(xmppConn, "someUser@gmail.com");

bq.

Edit: in doLoad(XmppConncention connection, String user) the PacketCollector receives only PacketReaders but no VCards, and I’m sure the user has one.

and next time I do:

bq. VCard vCard = new VCard();

bq. vCard.load(this);

Yeah! I was doing everything right, but tested with a Google account. I seems like it doesn’t support nicknames or at least it doesn’t use it as a display name. It all works fine with a jabber account.

Thanks again.