Basic Steps for Using MQTT in android

Johni Deep picture Johni Deep · Mar 5, 2012 · Viewed 67.5k times · Source

I am new to Android and want to use MQTT as push notifier for Android from Server.
i have read about MQTT but does not understand well. if any one has used this library so plz tell me what i have to do to start using it..

i have a Java Server (Running on Windows) and lots of Client(android phones on which my app will be installed). My server will send message to all or some specific clients at any time.

what are my basic requirement ? i mean is there

  1. server requirement ?
  2. some sort of registration ?
  3. Library to include in android ?
  4. identifier for Android device ? (as C2DM require Google account for each device)

plz help me in this regard

Answer

Andy Piper picture Andy Piper · Mar 5, 2012

You need:

  1. an MQTT broker which runs on the server side. This could be something like the mosquitto broker which is Open Source.
  2. an MQTT client library which you include in your Android app, enabling your app to connect, subscribe, and publish messages. There are a number of Java options listed at http://mqtt.org/software
  3. to come up with a way of uniquely identifying users or devices, and then use that as a topic so that you can individually publish a message to one device.

Dale Lane has written a nice guide on this (http://www.dalelane.co.uk/blog/?p=1599) and there is also a good set of resources about MQTT (https://github.com/mqtt/mqtt.github.io/wiki)