android - Best Practices for developing an Activity with a background Service -


my application has activity ui , service background polling fun. seems standard fare.

  1. can alarmmanager trigger service intent without activity oncreate being called?

  2. is there benefit putting activity & service different applications? create 2 apk's , make impossible put market 1 app? can put 2 applications 1 manifest somehow?

  3. regarding communication between two:

-if activity & service part of same application - can't store common objects (like user object) @ application scope 2 share?

-it seems don't need bother aidl - 2 have weak references each other @ application scope - , can call methods on each other way? or should pub/sub each other kind of observer pattern or broadcastlistener thing?

can alarmmanager trigger service intent without activity oncreate being called?

yes.

is there benefit putting activity & service different applications?

imho, no.

would create 2 apk's , make impossible put market 1 app?

yes.

can put 2 applications 1 manifest somehow?

from pure xml standpoint, there room in manifest more 1 <application> element. however, afaik, 1 supported.

if activity & service part of same application - can't store common objects (like user object) @ application scope 2 share?

for quick things, yes. however, bear in mind service may shut down (by android, user, etc.), after process may terminated, , application object goes poof. i'd use light caching only.

it seems don't need bother aidl

correct -- needed inter-process service binding.

the 2 have weak references each other @ application scope well

i wouldn't in million years. please use platform responsibly. there plenty of ways activities , services communicate yet remain loosely coupled (or, in case of local binding pattern, tightly-coupled in android-aware fashion).

or should pub/sub each other kind of observer pattern or broadcastlistener thing?

something along lines preferable. while activity , service may co-resident in same process @ same time, not designed directly linked 1 another.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -