AnsweredAssumed Answered

Smack 4.1.0 send message

Question asked by Tommy on Apr 25, 2015

I'm using smack 4.1.0 on Android. I want to send a message. But when I get message.getFrom(), it always return null.

Please help me!

 

===============================

String to = "xxxx";

ChatManager chatManager = ChatManager.getInstanceFor(connection);

  Message message = new Message(to, Message.Type.chat);

  message.setFrom(connection.getUser());

  message.setBody(text);

  message.addExtension(new DefaultExtensionElement("type_chat", "jabber:client"));

  message.addExtension(new DefaultExtensionElement("from", "jabber:client"));

  message.addExtension(new DefaultExtensionElement("to", "jabber:client"));

  chatManager.createChat(to).sendMessage(message);

  AppUtil.log("XMPP ===> chat sendMessage: " + message.getFrom() + " ==>\n " + message);

==============================

Outcomes