xmppsmackasmack

Smack Message.setType() doesn't work, type is set to 'chat'


I'm trying to send a Message with Type.headline

This is my code:

  public boolean sendText(Chat chat, String text) {
        Message message = new Message();
        message.setBody(text);
        message.setType(Message.Type.headline);
        message.setPacketID("id123456");
        try {
           chat.sendMessage(message);
           Log.d("TAG", message.toXML().toString());
           return true;
        } catch (SmackException.NotConnectedException e) {}
        return false;
}

But the XML that is sent, looks like this:

<message id='id123456' to='roee@192.168.0.3' type='chat'>
   <body>test message</body>
   <thread>ed108b04-4488-423a-a441-ca95284db6c1</thread>
</message>

As you can see, in the XML type='chat' instead of type='headline'.

Why is that and how do I change it?


Solution

  • Because you use a Chat to send the message.

    Simply use XMPPConnection.sendStanza(Stanza) (use sendPacket(Stanza) in older Smack versions) to send you message with type headline.