On Tue, Sep 4, 2012 at 11:55 AM, Justin Anderson <magouyaw...@gmail.com>wrote:

> there are callbacks to the ui, and recreating the ui while the service is
>> running would mean that i have to maintain a lot of status information in
>> the service, which is actually not the concern of the service at all... it
>> just does its work, and fires some events... which of course don't affect
>> the ui if the activity is finished....
>>
>
> I completely disagree here... In a good OO design the different states of
> the service should be maintained by the service, not by the Activity.
> Maintaining the state of the service anywhere else (like the UI) would lead
> to the service and the UI getting out of sync with one another... As an
> example, the service could be finished but the UI would be out of date and
> say that it is still running.


I agree with Justin here. In fact, I'd take it a step further - the logic
and state of whatever the Service is doing would be a completely separate
business object that does the real work and maintains the state or status
of that work. The Service is an Android-specific concept that you employ to
make this object "go". The Activity is an Android-specific concept that you
use to display the status of this business logic to the user.

So this object should be doing the bulk of the work and the Service and
Activity should merely be interfacing with it as necessary to accomplish
their own purposes.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to