Thanks a lot. I was really curious about what happens behind, and I
was afraid that trying to update a view while it wasn't displayed
would have broken something.

However, I choose the solution of unregistering the callback when my
activity is paused, and to ask the new status back to the service when
the activity is resumed again.

Thanks again for your help,

Federico


On Fri, Apr 22, 2011 at 6:42 PM, Dianne Hackborn <[email protected]> wrote:
> You can change your UI state while your activity is hidden.  That isn't
> going to break anything.  Typically in this state the window's surface has
> been destroyed so the view hierarchy won't do any draw or layout (until
> attached again), but that is not a problem.
> On the other hand, generally when one is in the background it is nice to use
> a little resources as possible, so usually people stop watching for changes
> at that point and refresh their state when next being resumed.  Or sometimes
> continue watching for changes but just note "something has changed" so when
> the user returns the UI can be refreshed only if something interesting has
> happened.
>
> On Thu, Apr 21, 2011 at 11:07 PM, Federico Paolinelli <[email protected]>
> wrote:
>>
>> Hi all..
>> I am trying to make the interaction with a background service work. As I
>> think it often happens, I need to call some method of the service from my
>> main activity, and I need to be notified about some state changes from my
>> service.
>> What I have done is to bind the background service from the activity, and
>> to pass it a callback interface to be called from the service. Now my
>> question: let's suppose that the callback updates some view (ie a textview)
>> with the state of the service. What should I do when the activity gets
>> paused? Should I unregister the interface (and check if the interface to be
>> called is not null in the service), like a basic observer pattern? And
>> again: what would happen if I do not unregister the interface, and the
>> service tries to update some gui element while the activity is not visible?
>> I know this would be solved using the intents - broadcast receiver to
>> notify the activity, but in my case the output given from the service is
>> supposed to vary often, and I feel binding the service is a more suitable
>> option in my case.
>> Hope I was clear enough,
>> Thanks a lot in advance
>>    Federico
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
--------
Federico

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

Reply via email to