I agree you should use a service.
But for optimization, i would use this method.

You should have a call to the service to query if the service is still
busy. If so, show a progress dialog and start listening to the service
to know when it no longer is busy (callback from the service into your
app)

On May 27, 4:07 pm, Robert Green <rbgrn....@gmail.com> 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 network service that I can register a specific callback with, like a
> "User Updated" callback, it would work really well.  When the service
> 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 <flyingdutc...@gmail.com> 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 <rbgrn....@gmail.com> 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 a callback so 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 the callback might 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 the callback, or set itself as the callback handler
> > > 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 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