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

