I'm searching all of the documentation I can find but I'm not seeing
any mechanism to register for callbacks from a service or to callback
to whatever handler is registered as the service.

I see the AIDL binding stuff, and so far I think maybe this sort of
thing might work?

Activity
-- Starts Service (this is to make the service keep going after this
context is destroyed)
-- Binds to Service, calls remote interface to check if the service is
busy, it's not, so nothing happens.
- User clicks on form submission
-- Starts Service (this is to make the service keep going after this
context is destroyed, it won't hurt to start again because it's
already running)
-- Binds to Service, calls remote interface to set self as callback
handler
-- Orientation change, destroyed
New Activity
-- Starts Service (this is to make the service keep going after this
context is destroyed)
-- Binds to Service, calls remote interface to check if the service is
busy, if so, sets self as callback handler
-- Service finishes working, calls back and ends itself.

Does this sound correct?  So far as I understand from the APIs, this
may be the only way to do it.  Please let me know of an easier way if
one exists!

Thanks!

On May 27, 3:22 pm, Streets Of Boston <[email protected]> wrote:
> I agree you should use aservice.
> But for optimization, i would use this method.
>
> You should have a call to theserviceto query if theserviceis still
> busy. If so, show a progress dialog and start listening to theservice
> to know when it no longer is busy (callbackfrom theserviceinto your
> app)
>
> On May 27, 4:07 pm, Robert Green <[email protected]> wrote:
>
> > I just looked at it.
>
> > 1)  They state that it is only an optimization and that you are not to
> > rely on the method being called.
>
> > 2)  My design is a little too complex to use that elegantly.  I do
> > network calls from multiple activities and some dialogs on those
> > activities, which need to chain to other actions upon completion.
>
> > I'm learning about Services right now and I think that if I could have
> > a networkservicethat I can register a specificcallbackwith, like a
> > "User Updated"callback, it would work really well.  When theservice
> > finishes updating a user, it simply notifies the user updated
> >callback.  It won't care if it was the original activity/dialog or a
> > new one.
>
> > Does that sound feasible?
>
> > On May 27, 2:22 pm, Streets Of Boston <[email protected]> wrote:
>
> > > Take a look at the method onRetainNonConfigurationInstance() of the
> > > Activity class. :-)
>
> > >http://developer.android.com/reference/android/app/Activity.html#onRe...()
>
> > > On May 27, 2:01 pm, Robert Green <[email protected]> wrote:
>
> > > > I have an app that communicates with a server.  While it is
> > > > communicating, it shows a progress dialog.  The way this actually
> > > > works is that I have a class that I call my NetworkGateway.  Each
> > > > method takes a Handler as acallbackso that the gateway can send back
> > > > the response as a bundle when it has finished.
>
> > > > Right now when someone changes orientation while a network operation
> > > > is occuring, the activity doesn't know that a thread is running the
> > > > network code and then thecallbackmight be invalid.
>
> > > > What's the right way to do this?  I want to make it so that after the
> > > > orientation switch, the activity can check something to see if a
> > > > network operation is running and if so, display the progress dialog
> > > > again and wait for thecallback, or set itself as thecallbackhandler
> > > > now, invalidating the old one.
>
> > > > My first guess is that this is exactly the kind of thing services were
> > > > designed for, but I'd like specifics if anyone can supply them.
>
> > > > Thanks!- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
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