How to make app connected in Android

Hello guys,

I have made an applicattion using smack for android. The application is almost done, but, i´m having a problem to keep the cliente connect even if the applicattion is closed.

The question is more about android then smack, but probably someone here know how to do it.

I think i need to use a service in background that have the listeners for messages, but, how to do it?

Thanks