Something similar to it is cross-posted here :

I am not getting replies there so posting it here again. I'm using smack 3.2

I have two queries:
1) How can we get the nick name or the name actual name of the user not the JID that is logging into chat. Suppose I log in to chat using smack api and I have email address of and my name stored on gmail is Roger then how can I get this name "Roger" ?

2) Second question is what I had written in above post on stackoverflow, I am looking to get previous status messages from gtalk server from the method described by google on but getting nothing in return. I get something like this only:

<iq id="2HyiB-4" to="" from="" type="result"></iq>

I am using this class to retrieve them:

class gtalksharedStatusPacket extends Packet {
     private String loginname;
     private String status;
     private int type;
     public gtalksharedStatusPacket (String _loginname) {
          loginname = _loginname;
     public gtalksharedStatusPacket (String _loginname, String _status) {
          loginname = _loginname;
          status = _status;
          type = 3;
     public void setType (int _type) {
          type = _type;
     public void setStatus (String _status) {
          status = _status;
     public String toXML () {
          String output = "";
          switch (type) {
               case 1: //client service discovery request
                    output += "<iq type='get' to=''>";
                    output += "<query xmlns=''/>";
                    output += "</iq>";
               case 2: //client request for status list
                    output += "<iq type='get' to='"+loginname+"'
id='"+Packet.nextID()+"' >";
                    output += "<query xmlns='google:shared-status' version='2'/>";
                    output += "</iq>";
               case 3: //update status
                    output  = "<iq type='set' to='"+loginname+"'
                    output += "<query xmlns='google:shared-status' version='2'>";
                    output += "<status>"+status+"</status>";
                    output += "<show>default</show>";
                    output += "<invisible value='false'/>";
                    output += "</query>";
                    output += "</iq>";
          return output;

And this is the same problem with all the google talk XMPP extensions described on

Ok, I got rid of my first problem of how to get a user's name. VCard class actually receive name from gtalk as First Name Field but shows null always. May be the function getFirstName() or the class itself has some bug. Anyways we can get the user name by calling the function getChildElementXML() of VCard which returns something like this:

<vCard xmlns='vcard-temp'><FN>Roger</FN></vCard>

There is your name, right inside <FN></FN> tags, you can get it by the help of substr method of String.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.