Best Practices for developing an Activity with a background Service?

From a pure XML standpoint, there is room in the manifest for more than one application element. However, AFAIK, only one is supported If Activity & Service are part of the same Application - can't I just store common objects (like User object) at the Application scope for the 2 to share? For very quick things, yes.

However, bear in mind that your service may get shut down (by Android, by user, etc. ), after which your process may get terminated, and your Application object goes poof I'd use this for light caching only It seems like I don't even need to bother with AIDL Correct -- that is only needed for inter-process service binding the two could just have weak references to each other at the Application scope as well I wouldn't do that in a million years. Please use the platform responsibly. There are plenty of ways for activities and services to communicate yet remain loosely coupled (or, in the case of the local binding pattern, tightly-coupled in an Android-aware fashion) Or should they pub/sub each other with some kind of Observer Pattern or BroadcastListener thing?

Something along those lines would be preferable. While the activity and the service may be co-resident in the same process at the same time, they are not designed to be directly linked to one another.

Yes. Is there any benefit to putting the Activity & Service into different Applications? IMHO, no.

Would this create 2 apk's and make it impossible to put into Market as one app? Yes. Can you put 2 applications into one manifest somehow?

From a pure XML standpoint, there is room in the manifest for more than one element. However, AFAIK, only one is supported. If Activity & Service are part of the same Application - can't I just store common objects (like User object) at the Application scope for the 2 to share?

For very quick things, yes. However, bear in mind that your service may get shut down (by Android, by user, etc.), after which your process may get terminated, and your Application object goes poof. I'd use this for light caching only.

It seems like I don't even need to bother with AIDL Correct -- that is only needed for inter-process service binding. The two could just have weak references to each other at the Application scope as well I wouldn't do that in a million years. Please use the platform responsibly.

There are plenty of ways for activities and services to communicate yet remain loosely coupled (or, in the case of the local binding pattern, tightly-coupled in an Android-aware fashion). Or should they pub/sub each other with some kind of Observer Pattern or BroadcastListener thing? Something along those lines would be preferable.

While the activity and the service may be co-resident in the same process at the same time, they are not designed to be directly linked to one another.

Thanks again CommonsWare - I'm really making progress towards proper design. More follow ups on the way. – paulpooch Feb 5 at 17:04 Question has led here: stackoverflow.Com/questions/4908267/… – paulpooch Feb 5 at 17:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions