Reputation: 1288
I am using a the Paho MQTT library for android and my application is exchanging live editing data. I want to disable an edittext if the app disconnects from the broker and enable it when connection is reestablished.
First part is easy enough the MqttCallback
has a connectionLost
method, but not reconnect. Also when debugging the the IMqttActionListener
on the connect method I noticed that the event is not fired upon a reconnect.
So my question is if there is any way at all to detect a reconnect?
Upvotes: 1
Views: 804
Reputation: 59608
Have a look at the extended version of the MQTTCallback class MQTTCallbackExtended.
It has a method called when a connection is established.
void connectComplete(boolean reconnect, java.lang.String serverURI)
Called when the connection to the server is completed successfully.
Parameters: reconnect - If true, the connection was the result of automatic reconnect. serverURI - The server URI that the connection was made to.
Upvotes: 5