Skip to content

Instantly share code, notes, and snippets.

@amanjeetsingh150
Last active September 23, 2018 12:59
Show Gist options
  • Save amanjeetsingh150/d64cfc3fee628a08855a3bc96a12e12c to your computer and use it in GitHub Desktop.
Save amanjeetsingh150/d64cfc3fee628a08855a3bc96a12e12c to your computer and use it in GitHub Desktop.
/**
* Used for subscribing to the topic.
*/
private void subscribeToTopic() {
try {
mqttAndroidClient.subscribe(subscriptionTopic, 0, null, new IMqttActionListener() {
@Override
public void onSuccess(IMqttToken asyncActionToken) {
Log.w(TAG, "Subscribed!");
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
Log.w(TAG, "Subscribed fail!");
}
});
} catch (MqttException ex) {
Log.e(TAG, "Exception whilst subscribing");
ex.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment