org.eclipse.paho.android.service.package.html Maven / Gradle / Ivy
Show all versions of org.eclipse.paho.android.service Show documentation
Contains a set of classes which allow an Android App to communicate
with an MQTT server using an Android Service.
The Android environment requires that a Service is used to support
such things as a long-lasting network connection.
This
package provides the classes need to implement such a Service to
interact with MQTT, together with an implementation of the
IMqttAsyncClient interface which uses the Service to implement the
interface operations.
The Service returns results via the Android Intent mechanism.
The MqttAndroidClient class shows how the interaction is
managed
Note: An App which uses this service must include the
appropriate Service tag in its manifest - e.g.
‹!-- Mqtt Service --›
‹service android:name="com.ibm.android.service.MqttService" /›
Note regarding network connectivity
The service does not attempt to track network state and automatically reconnect to MQTT servers as connectivity is lost and regained
While this is clearly possible, determining appropriate behaviour presents certain challenges.
Any maintainer adding support for such functionality should look to providing a BroadcastReceiver for
ConnectivityManager.CONNECTIVITY_ACTION probably as part of the MqttService object.
Changes in network connectivity would then need to be notified to the relevant MqttConnection objects.
The behaviour in response to changes in network connectivity would need to be considered in some detail - for example :-
- Should the behaviour differ for CleanSession=true vs CleanSession=false?
Remember that CleanSession=false will preserve subscriptions and messages with QOS > 0 should not be lost.
This would not be true for CleanSession=true;
- What is the meaning of the isConnected() in this context?