code: public LastActivity getLastActivity(Jid jid) throws NoResponseException, XMPPErrorException,
                      NotConnectedException, InterruptedException {
          LastActivity activity = new LastActivity(jid);
          return (LastActivity) connection().createStanzaCollectorAndSend(activity).nextResultOrThrow();
      }
docs: Returns the last activity of a particular jid. If the jid is a full JID
  (i.e., a JID of the form of 'user@host/resource') then the last activity
  is the idle time of that connected resource. On the other hand, when the
  jid is a bare JID (e.g. 'user@host') then the last activity is the lapsed
  time since the last logout or 0 if the user is currently logged in.
  Moreover, when the jid is a server or component (e.g., a JID of the form
  'host') the last activity is the uptime.
  
  @param jid
  the JID of the user.
  @return the LastActivity stanza of the jid.
  @throws XMPPErrorException
  thrown if a server error has occured.
  @throws NoResponseException if there was no response from the server.
  @throws NotConnectedException
  @throws InterruptedException