I am trying to change the Gtalk Status using XMPPConnection in Android. But when i am trying through Wi-Fi it is unable to connect. It is giving pop-up showing Application is not responding. My Code is here:
ConnectionConfiguration conn = new ConnectionConfiguration("talk.google.com",Integer.parseInt("5222"),"gmail.com");
m_xmppConnection = new XMPPConnection(conn);
conn.setSASLAuthenticationEnabled(false);
conn.setDebuggerEnabled(true);
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
try
{
m_xmppConnection.connect();
}
catch (XMPPException e1)
{
displayAlertDialog(e1.getMessage());
}
try
{
Log.d("Testing", "try to connect using XMPPConnection");
Log.d("Testing", "try to connect using XMPPConnection-----");
if(m_xmppConnection.isConnected())
{
Log.d("Testing", "It is connected with XMPPConnection");
m_xmppConnection.login(strUname, strPwd);
}
Log.d("Testing", "after giving user name and pwd-----");
Presence presence = new Presence(Presence.Type.available);
m_strGtPrevMsg = presence.getStatus();
m_spEditor.putString("prevmsg", m_strGtPrevMsg);
m_spEditor.commit();
presence.setStatus(strStatus);
Log.d("Testing", "status saved");
presence.setPriority(24);
presence.setMode(Presence.Mode.available);
m_xmppConnection.sendPacket(presence);
Log.d("Testing", "packet send");
}
catch(XMPPException e)
{
// e.printStackTrace();
displayAlertDialog(e.getMessage());
}
Can anyone help please.
My guess: You do the connection on the UI thread, right?
Make an AsnycTask and do your connection and status changes there.