When I started work on my Android XMPP client I wrote a service that handles all of the communication and the UI then communicates with the service. I am starting the service with a separate call to startService() so that it is not tied to the lifetime of the activity that starts it. Based on the info I had when I originally wrote that I believed that this required me to use AIDL to communicate with the service. It turns out that is not correct, though. AIDL is only needed when the service is in a different process and with this method it is not in a separate process. When I've had a few minutes here and there over the last couple of weeks I've rewritten the UI activities to just get a reference to the service and make calls to it as if it were any other object.

The biggest benefit from this is that I've got access to more of the XMPP info more easily. With AIDL all data passed around has to be a primitive data type or implement Parcelable. The asmack objects are neither of those. Most also hold a reference to the actual connection, so they could not be extended with a Parcelable child class. This meant I had to write a couple of super basic objects to hold the same data as the real asmack objects, but without the bits that made it impossible for them to be parcelable. I did end up keeping one of the new mini/wrapper objects around, though, since I need to pass that data through intents, which also need it to be parcelable.

I'm still kind of glad I did it with AIDL in the first place, though. That was something that doesn't get done very often and I think will still be good to know about and have experience with in the future.