有没有人使用过androidpn?当我连接服务器时,xmpp有这个错误:
02-27 21:24:34.720: D/RegisterTask.PacketListener(3144): packet=<iq id="8dMsj-0" from="kwant.cn" type="error"><query xmlns="jabber:iq:register"><password>abc</password><username>abc</username></query><error code="400" type="MODIFY"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
02-27 21:24:34.720: E/Androidpn_XmppManager(3144): Unknown error while registering XMPP account! bad-request
它暗示:XMPP连接成功。但它无法一直登录。我不知道为什么。
答案 0 :(得分:0)
我使用以下代码在Android中使用Smack API进行连接和登录,它就像魅力一样运行:
private XMPPClient xmppClient;
private XMPPConnection connection;
private ArrayList<String> messages = new ArrayList();
public void login(String userName, String password) throws XMPPException
{
ConnectionConfiguration config = new ConnectionConfiguration("HOST",PORT, "SERVICE");
connection = new XMPPConnection(config);
connection.connect();
//LOGIN USING THE FOLLWING login()
connection.login(userName, password);
xmppClient.setConnection(connection);
}