Skip to content

Instantly share code, notes, and snippets.

@beersheba
Created January 20, 2018 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beersheba/cf74a3027e3cede9f05d735395563649 to your computer and use it in GitHub Desktop.
Save beersheba/cf74a3027e3cede9f05d735395563649 to your computer and use it in GitHub Desktop.
private void subscribe() {
String subscribeTopic = "inbox";
try {
client.subscribe(subscribeTopic, 0, new IMqttMessageListener() {
@Override
public void messageArrived(final String topic, final MqttMessage message) throws Exception {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, message.toString(), Toast.LENGTH_SHORT).show();
}
});
}
});
} catch (MqttException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment