The Asmack is a patch of the Smack XMPP client library that has some fixes for Android. You can dig up what these patches are by reading this thread on Android Developers.
Anyway, there are numerous tutorials on how to integrate this library in an Android project, which is pretty simple (just download their jar and include it in the java build path).
What I was interested in this tiny test project was to see if the Smack spawns a new thread when I connect a MessageListener to listen for XMPP messages. That is useful for instance if you have a background Service that keeps a live-connection with a XMPP server in order to process the incoming messages. Since a Service in Android runs on the main thread of their host process, if I want to do intensive CPU or blocking operations (like networking), Android recommends spawning a new thread for them.
So I used this piece of code to connect a MessageListener and observe on which thread are messages received.
@Override
public void processMessage(final Chat chat, final Message message) {
Log.i(TAG, "Xmpp message received: '" + message.getBody() + "' on thread: " + getThreadSignature());
// --> this is another thread ('Smack Listener Processor')
}
Luckily, it does spawn its own thread (you can observe it in DDMS under the name ‘Smack Listener Processor’) in the Threads tab. So for instance, I think it’s safe to have your message parsed on this thread and then, if you need more expensive operations based on the content of the message, you can do it on a another thread and sync back with the Service’s thread via a Handler when it’s done. You can download the code for the project but you’ll need your own XMPP server to test it out. Enjoy!