On Apr 28, 3:43 pm, Dianne Hackborn <[email protected]> wrote:
> Another way you can approach this is to have a singleton that arbitrates
> access to the service -- it binds through the application context, and has a
> reference count of the current activities using it, to know when to unbind.
>  (If you care about unbinding, you very well may not.)  Then each activity
> gets this singleton, sets a callback, and update its UI when receiving the
> callback.  If the singleton is already bound to the service, it performs the
> callback immediately.

Thank you.  I think I'll go with this, since I am porting a Java
client application to Android, and I already have data transfer
mechanisms in place.

The main thing I was asking about is, if the Service that the Activity
needs is not created and/or connected yet, should the Activity handle
that gracefully and watch out for NPE's, etc, or should the Activity
just shut itself down in favor of a temporary "Please wait for data to
load...." Activity, that then starts the original Activity back up
again when the Service is finally ready.  It sounds like all the
advice so far is to write the Activity to work independent of Service
availability, and don't bother with the temporary "Please wait..."
Activity garbage.  The advantage of that approach would be that the
main data-bearing Activity may then be written knowing the data it
needs will always be at least available (i.e. non-null), albeit
possibly out of date.  But the advantage of the suggested approach is
certainly that the Activity would be much more resilient if it can be
displayed and interacted with, without the Service being available.

One of the problems I have is that I would like to share code with the
java client desktop application, and that is complicating matters for
sure.

-- 
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