Google Talk Status Update

I’ve spent the whole day trying to update my gtalk status automatically, but can’t seem to find out what’s wrong. I’m guessing it has to do with the bit on status updates on the Google Talk API page (see below).

Here’s my smack code:

// XMPP connection

**ConnectionConfiguration **cc = new ConnectionConfiguration(“”, 5222, “”);

**XMPPConnection **connection = new XMPPConnection(cc);



// Connect

System.out.print("Connecting... ");



// Login

System.out.print("Logging in... ");

SASLAuthentication.supportSASLMechanism("PLAIN", 0);

connection.login("", "pwd");

System.out.println("Authenticated? " + connection.isAuthenticated());

// New presence

**Presence **presence = new **Presence**(Presence.Type.available);


presence.setStatus("Some status");


// Sending new presence

System.out.print("Setting status... ");




**catch **(**XMPPException **e)




From the google page:

Google Talk User Status

If a user has “subscribed” to an app (has accepted an invitation or has invited the app to chat), the app can query whether a Google Talk user has a chat client running using the XMPP service API. The app can detect two possible status values: the user is connected, or the user is not connected. The app cannot determine the “away” status, nor can it determine the user’s status message.

An app can only query the status of Google Talk users, and only those that have “subscribed” to the app. There is no way for an XMPP service to query the status of users on other XMPP services.

App Engine reports a status of connected and available for all applications, regardless of whether the app supports receiving XMPP messages. There is no way to set a status message for an app.

Oh, and the application appears to be working.

Here’s my output:

Connecting… Done!
Logging in… Authenticated? true
Setting status… Done!

According to this page on the Google’s site, one has to set the presence in the following manner:

<iq type='set' to='' id='ss-2'>
  <query xmlns='google:shared-status' version='2'>
    <status>**Juliet's here**</status>
    <status-list show='default'>
        <status>Juliet's here</status>
        <status>Pining away</status>
        <status>Wherefor indeed</status>
        <status>Thinking about the sun</status>
    <status-list show='dnd'>
        <status>Chilling with Mercutio</status>
        <status>Visiting the monk</status>
    <invisible value='false'/>

Is there any way to send a string to the XMPP server without using the Presence class? I suppose one can delve into the source code, but that’s plan B at this stage.

I wrote a class that should get you started. The Google documentation you referenced is either wrong or misleading. When you send a query packet, the to="" should not contain the client’s identifier (in the examples its ‘orchard’). Using my class will erase your saved status messages, however. Google says you can get the current ones and resend them, but I couldn’t get it working.

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;

Just send a gtalksharedStatusPacket with XMPPConnection.sendPacket().

Shot Brad! I’ll give it a go.


Hello Brad,

I am trying to retrieve the list of recent status messages from something exactly same like your class but getting nothing and when I tried your class to get it, the problem remains the same. I tried to do exactly as discribed on

I used:

and in response I get:


Its the same story with every gtalk extension query, Service discovery is working fine but getting nothing in processing any extension query. Can you help with this?