Brussels / 31 January & 1 February 2015


XMPP and Android

Creating stable, reliable, push-enabled and battery friendly XMPP connections on Android

Using XMPP on resource constraint systems, like Android devices that are surrounded by a hostile mobile environment, imposes many challenges. But with the right measures a stable, reliable, push-enabled and battery friendly connection can be achieved. This talk will present the required techniques using Smack, an open source XMPP client library written in Java. One outstanding property of Smack is that it's a multi-runtime library, i.e. it is able to run on Java SE runtimes and on Android.

XMPP on Android is challenging. But with Smack there exists an open source XMPP client library written in Java, that is able to run natively on Java SE runtime environments and on Android. Smack is a lightweight, resource friendly and highly modular library. Ideal for the deployment in low-end devices. But the mobile usage scenario of Android devices poses another obstacle towards a stable and reliable (mobile) XMPP connection. Data connectivity changes, caused for example when a GSM ↔ WiFi switch happens, and high latency, are just some effects of such a mobile environment. With XEP-198 Stream Management, XMPP provides the ideal extension to tackle those issues. Using XEP-198 Stream Management enabled connections, data connectivity changes become transparent to the application.

Another obstacle imposed by Android is caused by the device entering the so called "deep sleep" mode. While incoming radio activity usually causes the device to leave the sleep, it's not guaranteed that it will not re-enter the sleep before the XMPP stanza has been fully processed. There are some forms of possible mitigations conceivable. But which are good? And which are just snake oil?

I'll start with a short introduction of XMPP and Smack and explain how Smack is able to target Android and Java SE runtimes. The rest of the talk will consist of best practices using Smack on Android and how Smack can be used for stable, reliable XMPP connections and push notifications.


Florian Schmaus