Is that possible?

I have a bind between my Service and the Activity at the minute but when I
try to change to aidl file to allow me pass the RingTone object it wont
compile for me, saying RingTone and com.android.RingTone cannot be
resolved/found

On Fri, Sep 10, 2010 at 1:34 PM, Federico Paolinelli <[email protected]>wrote:

> One way I would try is to bind your activity to the service and give
> the service a callback to be called when you asynctask has finished
> its dirty job. (I've never done this, but it may work).
> You can provide your ringtone object as argument of the callback.
>
>
>
> On 10 Set, 13:38, Donal Rafferty <[email protected]> wrote:
> > Excellent idea Federico, However my AsyncTask fetches a RingTone object
> > (com.android.RingTone) and I have no way of passing this object from my
> > Service to my Activity?
> >
> > On Fri, Sep 10, 2010 at 11:36 AM, Federico Paolinelli <
> [email protected]>wrote:
> >
> > > You could probably move the async task to a service, and broadcast all
> > > your stuff when you finish.
> > > If your activity listens for the broadcast, it won't matter if the
> > > activity itself started the service, or if it was started by another
> > > activity (of the same kind).
> >
> > > Federico
> >
> > > On Sep 10, 12:14 pm, Donal Rafferty <[email protected]> wrote:
> > > > Thanks for that Shawn, but I'm looking for a solution that doesn't
> > > involve
> > > > external libraries.
> >
> > > > On Fri, Sep 10, 2010 at 10:45 AM, Shawn Brown <
> > > [email protected]>wrote:
> >
> > > > > > Has anybody got any idea why this would be happening?
> >
> > > > > Well...  from
> > > > >
> http://brainflush.wordpress.com/2009/11/16/introducing-droid-fu-for-a.
> > > ..
> >
> > > > > So the basic idea is: launch an AsyncTask making your service call,
> > > > > show a nifty progress dialog while the task thread is running, and
> > > > > have the task’s result be posted back to your activity once it
> > > > > completes. Cool, but what if the user decides to rotate the screen
> > > > > while your task is running? Or a phone call comes in, interrupting
> > > > > your app, and Android decides to kill it? Both these actions will
> > > > > effectively terminateyour activity, and recreate it when resuming
> > > > > (yes, a screen rotation kills your activity, very clever, isn’t
> it?).
> > > > > Unfortunately, any AsyncTask that was still running now holds a
> stale
> > > > > reference to your activity, because the restarted activity will be
> an
> > > > > entirely different object in memory (and it will go through
> > > > > onCreate(), as if the activity had started for the first time). I’m
> > > > > not entirely sure whether AsyncTask will actually post back the
> data
> > > > > to the old activity object (if it was a weak reference, it may
> already
> > > > > have been garbage collected), but in any case, your “new” activity
> > > > > will never see it, because it’s a different instance.
> >
> > > > > Now, one could argue: well, just do all the work again, like,
> re-send
> > > > > the request or whatever job was running. Yes, you could do that.
> But
> > > > > that’s wasteful and, really, makes you feel stupid, no? Plus, if
> the
> > > > > user triggers a web service request, then flips the screen, decides
> > > > > that this wasn’t helpful, and flips it back, then your request is
> > > > > being sent 3 times in parallel. Is that what you want? Probably
> not.
> >
> > > > > BetterAsyncTask to the Rescue
> >
> > > > > Thanks to Droid-Fu, there’s a solution to this: BetterAsyncTask!
> (I’m
> > > > > a lazy person, and I couldn’t come up with a better name). It
> behaves
> > > > > exactly like AsyncTask (in fact, it is an AsyncTask), but it does
> some
> > > > > extra work for you: first and foremost, it keeps track of the
> active
> > > > > instance of the context that launched it, and if that instance
> should
> > > > > change, it will post the data back to the new instance. In other
> > > > > words, you can dispatch your task, flip the screen back and forth
> > > > > mentally, and BetterAsyncTask will still post the task’s result
> back
> > > > > to whatever activity instance is alive at the time it finishes. In
> > > > > other words, the task is only ever run once, regardless whether the
> > > > > context in which it was launched died while it was running or not.
> >
> > > > >http://github.com/kaeppler/droid-fu
> >
> > > > > --
> > > > > 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]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > <android-developers%[email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> >
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
> >
> > > --
> > > 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]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

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