I tried to set online mode but it doesn't work through a Roster. I ran this code and check my localhost server, the mode still "available" and not "Do not disturb".
final Connection connection = new XMPPConnection("xxx.xxx.x.xx");
connection.connect();
connection.login("hieugioi@hieund", "123456");
final Roster roster = connection.getRoster();
Presence p = roster.getPresence("hieugioi@hieund");
p.setPriority(128);
p.setMode(Mode.dnd);
Because you don't send the Presence packet to the server. After you have assembled your Presence packet you need to send it. For example:
Presence p = new Presence(available, "I am busy", 42, Mode.dnd);
connection.sendStanza(p);
See also: Smack - Getting Started; section "Reading and Writing Packets"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With