This is a sample that will help set the status message to gtalk.
import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.packet.Presence; public class SmackToGtalk { public static void main(String[] args) { ConnectionConfiguration config = new ConnectionConfiguration( "talk.google.com", 5222, "google.com"); XMPPConnection connection = new XMPPConnection(config); Presence presence; String status; try { connection.connect(); connection.login(" mail_id@gmail.com ", "password"); status = "DND"; presence = new Presence(Presence.Type.available, status, 24, Presence.Mode.available); while (true) { status = set(status); presence.setStatus(status); connection.sendPacket(presence); Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); } finally { connection.disconnect(); } } private static String set(String input) { return input.substring(1) + input.charAt(0); } }
source share