service - Recommendation for a configurable Android application that performs a task frequently -
i trying create android application following:
- on installation gives user ui in allowed enter gmail id/password , twitter id/password.
- 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.
- if arrived email in specified format, starts tweeting twitter account.
- 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.)
- 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:
to keep running on phone restart , after long interval of time. in short forever.
the tweeting task continue in case there phone restart in between.
so questions are:
- 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.
- the thread created tweeting must not stop if phone restarted.
- 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.
- you can subscribe event indicates phone has booted (
android.intent.action.boot_completed).alarmmanagerrestart service periodically although don't overdo it.timertaskwon't work if application gets killed, there's nothing run task. - same thing. work in
service.
if have intentservice implementation working, it's not bad choice offloads work off main thread.
Comments
Post a Comment