How to maintain/restart XMPP connection when android app is killed?

Hi Guys,

I am making a chat application and I want a similar behaviour like Whatsapp. He maintains the XMPP connection even if the app is killed. I am using service that runs even after the app is killed. So, initially the connection is established by the activity and the service is started. When I kill the app, the service restarts (this is what happens in Whatsapp) and I create a connection there. But it always gives me exception there.

Can someone help?

Logcat output:

System.err﹕ org.jivesoftware.smack.SmackException$ConnectionException

System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC

System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.

System.err﹕ at org.jivesoftware.smack.XMPPConnection.connect(

System.err﹕ at com.iflylabs.iflychat.iFlyChatMessage.connect(

System.err﹕ at com.iflylabs.iflychat.iFlyChatMessage.onCreate(

System.err﹕ at

System.err﹕ at$1600(

System.err﹕ at$H.handleMessage(

System.err﹕ at android.os.Handler.dispatchMessage(Handler.

System.err﹕ at android.os.Looper.loop(

System.err﹕ at

System.err﹕ at java.lang.reflect.Method.invokeNative(Native

System.err﹕ at java.lang.reflect.Method.invoke(

System.err﹕ at

System.err﹕ at

System.err﹕ at dalvik.system.NativeStart.main(Native Method)

Hello friend,

Did you solve your problem? How did you do?