Android - Background thread to renew PHP session -
i'm wondering if there way, run background thread, works behind activities. need renew session on php server in mobile app, don't want make in doinbackground of every asynctask class, in thread works behind activities , connects server every 15 minutes, renew session, can store sid in database, , use every time need in requests.
i read handler , service, understood, work in specific activity, not in background of entire application, , can't renew session them need. wrong?
or can handled somehow robospice lib? heard it, never checked features.
sorry if missed similar question asked , answered.
robospice designed make easy write network requests executed in background. so, yes, can extend session on server side client side.
nevertheless, robospice has nothing timer. so, achieve this, need :
- to use alarm manager of android
- then give pending intent wake service of own
- this service can use robospice create network request extend server's session.
details here : http://developer.android.com/training/scheduling/alarms.html
don't forget unregister alarm manager when don't need session extension anymore or drain battery.
Comments
Post a Comment