AnsweredAssumed Answered

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

Question asked by Prateek Grover on Apr 22, 2015
Latest reply on Jan 28, 2016 by Gustavo

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 onnection.java:436)

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 android.app.ActivityThread.handleCreateService(

System.err﹕ at android.app.ActivityThread.access$1600(

System.err﹕ at android.app.ActivityThread$H.handleMessage(

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

System.err﹕ at android.os.Looper.loop(Looper.java:153)

System.err﹕ at android.app.ActivityThread.main(ActivityThread.

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

System.err﹕ at java.lang.reflect.Method.invoke(Method.java:511)

System.err﹕ at com.android.internal.os.

System.err﹕ at com.android.internal.os.ZygoteInit.main(

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

Outcomes