The Android™ API is bundled in a JAR file and is supported
on Android KitKat and later.
Get the Android SDK as a JAR:
The JAR file is also located in your Diffusion™
Table 1. Supported platforms and transport protocols for the
||Minimum supported versions
||Supported transport protocols
||API 19 / v4.4 / KitKat and later
Note: Push Technology provides
only best-effort support for Jelly Bean (API 16-18, v4.1-4.3).
Considerations and capabilities that are specific to the Android
- Diffusion connections
- Ensure that you use the asynchronous open() method with a callback.
Using the synchronous open() method might open a connection on the
same thread as the UI and cause a runtime exception. However, the synchronous
open() method can be used in any thread that is not the UI
- Applications in background state
Android applications can be sent to the background
and their activity stopped. When this happens your application is notified by the
onStop() callback of the Android
Activity class. An application's activity can be stopped when the
user switches to another application, starts a new activity from within the
application, or receives a phone call.
When your application's activity is stopped, we recommend that it saves its state
locally – in particular, any topic subscriptions it has made – and closes
its client session with the Diffusion server. When the Diffusion app returns to the foreground, open a new client
session with the Diffusion server and use the saved state to restore
For more information, see the Android Activity
Lifecycle documentation and Stopping and Restarting an Activity.
Consider using push notifications to deliver data to your
users when your client application is in background state. For more information, see
Push notification networks.
- Writing good callbacks
- The Android client library invokes callbacks using a
thread from Diffusion thread pool. Callbacks for a particular
session are called in order, one at a time. Consider the following when writing
- Do not sleep or call blocking operations in a callback. If you do so, other
pending callbacks for the session are delayed. If you must call a blocking
operation, schedule it in a separate application thread.
- You can use the full Diffusion API to make other
requests to the server. If you want to make many requests based on a single callback
notification, be aware that Diffusion client flow control
is managed differently in callback threads. Less throttling is applied and it is
easier to overflow the servers by issuing many thousands of requests. If you have a
lot of requests to make, it is better to schedule the work in an application
- Regular expressions
- The Android client uses the same regular expression
engine to the Diffusion server. Some regular expressions in topic selectors
are evaluated on the client and others on the Diffusion server. There is no
difference in how these regular expressions are evaluated in the Android client.