service - Recommendation for a configurable Android application that performs a task frequently -


i trying create android application following:

  1. on installation gives user ui in allowed enter gmail id/password , twitter id/password.
  2. the user clicks on button launches service runs in background check gmail account new mail arrival. service should keep running forever after ui(activity) removed foreground.
  3. if arrived email in specified format, starts tweeting twitter account.
  4. the tweets based on contents of mail , may numerous. these tweets go after interval of time, 3 mins. hence tweeting task may take hours complete.(with phone sleep/restart in between.)
  5. the service/background task must stoppable , resume again in case if user decided change gmail/twitter credentials.

i have implemented service(intent service more general) check gmail inbox new mail arrival. how gets killed after time , on phone restart. want service:

  1. to keep running on phone restart , after long interval of time. in short forever.

  2. the tweeting task continue in case there phone restart in between.

so questions are:

  1. how create forever running service? have searched other similar question , found 2 solutions-alarmmanager , timertask. not sure if alarmmanager keep on starting service again , again in case had been killed.i tried timertask not resume once phone reboots. maybe subscribe service system service resume automatically on phone reboot.
  2. the thread created tweeting must not stop if phone restarted.
  3. the service must allow stopped , resumed new credentials if user changes ui.

also wanted know if intentservice case or simple service suffice? comparatively new android development , expect more experienced ones share views related requirements.

  1. you can subscribe event indicates phone has booted (android.intent.action.boot_completed). alarmmanager restart service periodically although don't overdo it. timertask won't work if application gets killed, there's nothing run task.
  2. same thing. work in service.

if have intentservice implementation working, it's not bad choice offloads work off main thread.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -