get gmail user available status
I have email list for my gmail id...it got using XMPP...how can i get those 开发者_运维百科user status availability in java...
Here is an example using Smack
SASLAuthentication.supportSASLMechanism("PLAIN");
ConnectionConfiguration config = new ConnectionConfiguration(
"talk.google.com", 5222, "gmail.com");
XMPPConnection conn = new XMPPConnection(config);
conn.connect();
conn.login("yourid@gmail.com", "password");
Roster roster = conn.getRoster();
Collection<RosterEntry> set = roster.getEntries();
for (RosterEntry re: set) {
System.out.println(">> " + re.getUser());
Presence pres = roster.getPresence(re.getUser());
//This is the status.
System.out.println("\t> " + pres.getMode());
}
Use Prescence.getStatus()
to get the message string
精彩评论