Send message using Smack 4.1.0 in Android

Hi, I’m using Smack 4.1.0 in Android and Openfire 3.10.0 as server. I created a user called admin in the server, and I’m trying to send a message to him, but I don’t know exactly how to do, I’ve tryed many sugestions but none seems to work. I can connect and login to the server with no problems, but the messages aren’t send, I’m logged with the user admin in Spark, and I see the user logged in my application as online, but the messages sent don’t show. I’m doing all that with my pc as server. Here how I’m trying:


XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();

config.setUsernameAndPassword(sUser, sSenha);

config.setServiceName(“languagechat”);

config.setHost(“192.168.25.97”);

config.setPort(5222);

AbstractXMPPConnection con = new XMPPTCPConnection(config.build());

try{

\here connects normal

con.connect();

\login works fine too

con.login();

\that’s how I’m trying to send the message

String to = “admin”;

String from = con.getUser();

ChatManager chatManager = ChatManager.getInstanceFor(con);

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

message.setFrom(from);

message.setBody(sMensagem);

message.addExtension(new DefaultExtensionElement(“from”,from));

message.addExtension(new DefaultExtensionElement(“to”, to));

con.sendStanza(message);

} catch (IOException e){

con = null;

return false;

} catch (SmackException e){

con = null;

return false;

} catch (XMPPException e){

con = null;

return false;

}finally {

return true;

}


If someone could help I would appreciate.

You must specify a bare or full Jid as ‘to’.

What should be the full Jid? By example, I can log just with “admin”, to send to “admin” a message, what should I put together to form a Full Jid?

Thanks by your answer! Now I managed to send the message, I used my connection con.getUser();, then this showed exactly how I supposed to fill the user with the Full Jid.
Thanks a lot! This really helped me.