android - Activity with Long running task -


i developing android app long running task either invoked user or scheduled alarm.

i have designed in activity - > service - > asynctask form of invocation.

i use otto library bring ui updates directly asynctask activity.

i have 2 question:
1 there reason should use otto communication asynctask - > service , service - > activity. have seen lots of apps use pattern.

2 when should run service in foreground ? argument of not being killed low memory can abused. want make conscious decision. believe should run in foreground when invoked user manually , not when kicked alarm.

i use otto library bring ui updates directly asynctask activity.

note event buses may or may not, deliver events in sequence (pre/post). besides, otto, can post events on main threads thread. simple runnable can replace asynctask.

1 there reason should use otto communication asynctask - > service , service - > activity. have seen lots of apps use pattern.

some client --> service -- > executor queue --> model/data changes --> broadcast otto events --> interested clients update views model/data.

2 when should run service in foreground ? argument of not being killed low memory can abused. want make conscious decision. believe should run in foreground when invoked user manually , not when kicked alarm.

service should able survive re-starts. @ boot checks pending tasks in queue , resumes them. should shut down when no pending tasks. should start when new task posted.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -