Android 尝试使用XMPPClient设置GTalk的状态时获取异常

Android 尝试使用XMPPClient设置GTalk的状态时获取异常,android,Android,我想使用我的应用程序更改我的gtalk的状态。为此,我使用smack API和XMPPClient。但我在设置连接时遇到异常。这是我的密码: try { ConnectionConfiguration conn = new ConnectionConfiguration("talk.google.com",Integer.parseInt("5222"),"gmail.com"); Log.d("Debug", "configuration object

我想使用我的应用程序更改我的gtalk的状态。为此,我使用smack API和XMPPClient。但我在设置连接时遇到异常。这是我的密码:

try
    {
        ConnectionConfiguration conn = new ConnectionConfiguration("talk.google.com",Integer.parseInt("5222"),"gmail.com");
        Log.d("Debug", "configuration object has been created");
        conn.setSASLAuthenticationEnabled(true);
        conn.setDebuggerEnabled(true);
        m_xmppConnection = new XMPPConnection(conn);
        m_xmppConnection.connect();
        Log.d("Debug", "try to connect using XMPPConnection");
        m_xmppConnection.login("yyy", "xxx");
        Presence presence = new Presence(Presence.Type.available);
        presence.setStatus("Setting the status Programmatically");
        presence.setPriority(24);
        presence.setMode(Presence.Mode.available);
        m_xmppConnection.sendPacket(presence);

    }

    catch(XMPPException e)
    {
        e.printStackTrace();
    }
我使用的是Android 2.2,并添加了smack 3.2.1 jar文件。它没有从服务器发出响应

这是logcat中的错误

     11-15 18:40:28.301: W/System.err(7865): Connection failed. No response from server.: 
11-15 18:40:28.311: W/System.err(7865):     at org.jivesoftware.smack.PacketReader.startup(PacketReader.java:120)
11-15 18:40:28.311: W/System.err(7865):     at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:606)
11-15 18:40:28.320: W/System.err(7865):     at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:565)
11-15 18:40:28.320: W/System.err(7865):     at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:991)
11-15 18:40:28.320: W/System.err(7865):     at com.innominds.ui.Notification.setStatusGtalk(Notification.java:519)
11-15 18:40:28.320: W/System.err(7865):     at com.innominds.ui.Notification.onClick(Notification.java:238)
11-15 18:40:28.320: W/System.err(7865):     at android.view.View.performClick(View.java:2408)
11-15 18:40:28.320: W/System.err(7865):     at android.view.View$PerformClick.run(View.java:8816)
11-15 18:40:28.320: W/System.err(7865):     at android.os.Handler.handleCallback(Handler.java:587)
11-15 18:40:28.343: W/System.err(7865):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-15 18:40:28.343: W/System.err(7865):     at android.os.Looper.loop(Looper.java:123)
11-15 18:40:28.343: W/System.err(7865):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-15 18:40:28.343: W/System.err(7865):     at java.lang.reflect.Method.invokeNative(Native Method)
11-15 18:40:28.343: W/System.err(7865):     at java.lang.reflect.Method.invoke(Method.java:521)
11-15 18:40:28.343: W/System.err(7865):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-15 18:40:28.351: W/System.err(7865):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-15 18:40:28.351: W/System.err(7865):     at dalvik.system.NativeStart.main(Native Method)

为什么我会收到这个消息?任何人都可以告诉我或帮助我吗?

我看到的清晰执行是这样的,你正在登录,然后很快你就设置了状态和状态,这是无效的。所以它肯定会给你错误。您需要等待登录过程完成,然后才能设置状态


请访问www.gmail.com或https://www.gmail.com

我添加了logcat错误。请检查。实际上它并没有创建ConnectionConfiguration对象。在第一行中,我得到了一个例外。我认为对于android,您还需要为配置提供端口号5222是的,我更改了代码。但是现在我得到了不同的异常。11-23 17:42:58.794:W/System.err9885:XMPPError连接到talk.google.com:5222:remote-server-error502 XMPPError连接到talk.google.com:5222.5222端口应该为连接打开请检查