1
我正在使用smack发送聊天消息。在测试中我发现,当网络不可访问时,API不会抛出任何异常。如何使用Smack发送聊天时检测到错误
我的代码:
Chat chat = connection.getChatManager().createChat(
"[email protected]", new MessageListener() {
@Override
public void processMessage(Chat arg0, Message arg1) {
System.out.println(arg1.getFrom() + " says " + arg1.getBody());
}
});
// I Put a break point here and deliberately disable the network.
// But the following line is not throwing the XMPPException
chat.sendMessage("smack says hi.."); /* Send the message  */
我应该添加任何侦听器来捕获异常?
试试这个:http://xmpp-tutorials.blogspot.com.br/ – Richard 2014-06-30 23:27:40