Why debug window got incoming message but nextMessage() not?!

try {

System.out.println(“1!!!”);

XMPPConnection connection = new XMPPConnection(host);

System.out.println(“2!!!”);

connection.login(user, pwd);

System.out.println(“3!!!”);

Chat newChat = connection.createChat(sender);

System.out.println(“4!!!”);

newChat.sendMessage("[" + subject + "] " + content);

System.out.println(“5!!!”);

Message msg = newChat.nextMessage();

if (msg != null)

{

System.out.println(“8!!!” + msg.getSubject() + msg.getBody());

}

newChat.sendMessage(msg);

}

catch (Exception e) {

System.out.println(“exception!!!”);

}

return 0;

i solved this problem by myself ,just Chat.setFilteredOnThreadID(false);.

however, r u guys sure this is a good trick?

That setting is useful when other clients (not Smack) don’'t send a element in the xml packet. In those cases, the only way to find out that a message belongs to a chat is by filtering on the sender of the messages instead of the element.

So the answer is yes if your client is not sending the element.

Regards,

– Gato