kizen
October 29, 2017, 11:14am
1
i copy the code from the offical websitehttp://download.igniterealtime.org/smack/docs/latest/documentation/messaging.html
but the IDE show The type ChatManager is deprecated
is that wrong?
ChatManager chatManager = ChatManager.getInstanceFor(connection);
chatManager.addListener(new IncomingChatMessageListener() {
@Override
void newIncomingMessage(EntityBareJid from, Message message, Chat chat) {
System.out.println("New message from " + from + ": " + message.getBody());
}
});
EntityBareJid jid = JidCreate.entityBareFrom("jsmith@jivesoftware.com");
Chat chat = chatManager.chatWith(jid);
chat.sendMessage("Howdy!");
}
kizen
October 29, 2017, 11:14am
2
and the IncomingChatMessageListener Class can not used here
There is:
org.jivesoftware.smack.chat.ChatManager
which is deprecated and new one:
org.jivesoftware.smack.chat2.ChatManager
which you should use.
Hi,
This is my first time using Smack.
I’m unable to receive the incoming message in the method newIncomingMessage(…)
What could be the issue?
The message was sent successfully as I can see in the logcat.
How did you register the IncomingMessageListener?
Found my mistake.
I was setting this to false after a couple of statements: configuration.setSendPresence(true );
Thanks