2011-11-02 34 views

回答

1

如果使用Smack API針對Android:

// Create the presence object with default availability 
Presence presence = new Presence(Presence.Type.available); 

// Set the status message 
presence.setStatus("Lame status is lame"); 

// Set the highest priority 
presence.setPriority(24); 

// Set available presence mode 
presence.setMode(Presence.Mode.available); 

// Send the presence packet through the connection 
connection.sendPacket(presence); 
+0

所以這意味着,從我的應用程序,首先我必須與gmail id或gtalk連接。然後使用Presence,我可以改變狀態。 –

+0

是的,你必須做一個[XMPP連接](http://www.adarshr.com/papers/xmpp2) – Reno

+0

我們可以使用帳戶和帳戶管理員類來做到這一點嗎?因爲我可以使用這個獲得Gmail的身份證。 Account [] accounts = AccountManager.get(this).getAccountsByType(「com.google」); String myMailId = accounts [0] .toString(); –

相關問題