我想使用我的应用程序更改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)
为什么我能得到这个,任何人都可以告诉或帮助?
答案 0 :(得分:0)
我看到的明确执行就像是,你正在进行登录,很快就会设置存在和状态,这是无效的。所以它肯定会给你错误。您需要等到登录过程完成后才可以设置状态或状态
尝试使用“www.gmail.com”或“https://www.gmail.com”