Sorry I meant only the preExecute is run On Mon, Sep 13, 2010 at 1:05 PM, Donal Rafferty <[email protected]> wrote:
> I have managed to implement the Task in my Service now but the original > problem still remains. > > I dont cancel the Task at all in my service, I simply play the ringtone in > the postExecute method of the Asynctask if a flag is true, if its not I > dont. > > But I get the same issue, after a couple of runs the AsyncTask simply stops > getting to the doInBackground method, only the postExecute method is run. > > Its very strange and really annoying me now. > > Is there any reason why an AsyncTask would behave like this without cancel > being used? > > > On Mon, Sep 13, 2010 at 10:58 AM, Donal Rafferty <[email protected]>wrote: > >> Monday morning coding! :) >> >> I return my aidl definition in my service's onBind: >> >> @Override >> public IBinder onBind(Intent arg0) { >> Log.d("XXX", "Status: onBind Called"); >> return myServiceStub; >> } >> >> IBinder myServiceStub = new IMyService.Stub(){ >> >> //aidl methods >> >> }; >> >> And use this to call methods from my Activity, so I would need to be able >> to import android.media.Ringtone in my aidl definition but I cant. >> >> So I'm still stuck with it not working :( >> >> >> On Mon, Sep 13, 2010 at 10:32 AM, Kostya Vasilyev <[email protected]>wrote: >> >>> Donal, >>> >>> No, a service is a service, and a binder is a binder. >>> >>> The binder you get in the callback is the binder returned by the >>> service's onBind. >>> >>> This example: >>> >>> >>> http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LocalService.html >>> >>> has a binder implementation that returns a reference to its service, so >>> you can do this >>> >>> public void onServiceConnected(ComponentName className, >>> IBinder binder) { >>> >>> LocalService.LocalBinder binder = (LocalService.LocalBinder) binder; >>> *LocalService service = binder.getService();* >>> } >>> >>> This example has one flaw: it leaks a service reference (since >>> LocalBinder is a non-static inner class of LocalService). Using a static >>> inner or a top-level class for LocalBinder, fixes that (AFAIK). >>> >>> -- Kostya >>> >>> 13.09.2010 13:16, Donal Rafferty пишет: >>> >>> 09-13 10:06:53.566: ERROR/AndroidRuntime(18791): Uncaught handler: thread >>> main exiting due to uncaught exception >>> 09-13 10:06:53.676: ERROR/AndroidRuntime(18791): >>> java.lang.ClassCastException: com.xxx.phone.MyService$1 >>> 09-13 10:06:53.676: ERROR/AndroidRuntime(18791): at >>> com.xxx.phone.ui.MyActivity$2.onServiceConnected(MyActivity.java:515) >>> >>> So it doesn't like the cast from binder to Service? >>> >>> How can I fix that do you know? What am I missing from the example? >>> >>> >>> >>> -- >>> Kostya Vasilyev -- WiFi Manager + pretty widget -- >>> http://kmansoft.wordpress.com >>> >>> -- >>> 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

