Hello,
i am trying to implement a persistant XMPP connection using aSmack. I came upon a few problems.
What i have so far:
I create a new TCPConnection with PingManager(every 10s) in a Thread in my foreground serivce. setReconnectionAllowed ist true.
I noticed that after some random time the connection fails. I think this is beacause the CPU goes into sleep mode, shouldn't the PingManager/KeepAliveManager handle this for me?
I haven't tried pinging the server manualy using Androids AlarmManager which should wake the CPU for me yet.
Looking at the Xabber src(they bring their own smack fork) i saw a loop using a Handler and postDelayed in their code, checking if the connection is alive every second and reconnecting if it is not - without wakelocks as far as i can tell(turned of in settings).
Any hints how to implement a "persistant connection" the best way on Android? Aquireing wakelocks should work, but i think that is a very bad solution.
Some other useful information: Phone is a Nexus 4 with KitKat and i am developing for ICS and newer.
Thanks and and i know my english isn't the best