Yup, I found it.
RemoteService.java
IRemoteService.aidl
IRemoteServiceCallback.aidl
Is that what you're talking about?
I'm looking at those now and am going to try to code this up in the
next few hours.
On May 27, 4:08 pm, Streets Of Boston <***@gmail.com> wrote:
> Your steps below are basically correct, but take a look at the API
> Demoes source code.
> There is one for demoeing how to write a Service, using AIDL.
> It also shows how to write a callback method (service calling back
> into activities bound to that service).
>
> I use it for monitoring image-upload progress. The activity binds to
> the service and registers itself as interested in upload progress.
> When the service is uploading images, it calls back to any registered
> activity. The activity then updates, on these callbacks, various
> progress indicators.
>
> On May 27, 4:33 pm, Robert Green <***@gmail.com> wrote:
>
> > 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 <***@gmail.com> 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 <***@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 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 <***@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 <***@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 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 -- Hide quoted text -
>
> > - Show quoted text -
>
>