Keep XMPP connection (using asmack) alive on Android -


i'm developing application receives push notifications via xmpp ( know c2dm, has limitations , can't use because of ), problem connection after time garbage collected , can't send push notification android device.

i think need implement android service have no idea how implement service keep connection alive. me?

i not sure if "garbage collected" right term here. more activity gets closed android, because create connection in activity.

but right, in order keep stable connection need put xmpp connection service. make sure connection in thread, because service not process or thread. done, example handler.

handlerthread thread = new handlerthread(service_thread_name); thread.start(); handlerthreadid = thread.getid(); servicelooper = thread.getlooper(); servicehandler = new servicehandler(servicelooper); 

then can communicate service thread via messages/intents. alternative binder interface.

you have on how others this: beem , gtalksms both open source projects implement xmpp connection android service. gtalksms uses intentservice approach, whereas beem uses binder communicate xmppconnection.

note achive pretty stable connection gtalksms, it's never stock gtalk service/client. 1 reason smacks default keep-alive check timer 5 minutes, way mobile device when want save battery possible. had set higher value, comes drawbacks. have trade-off between fast, responsive , stable connection vs. battery life when comes this.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -