Hey Marco, actually I tried that and hit a ReceiverCallNotAllowedException [1] . But after using the ApplicationContext this seems to work fine.
Cheers, Mariano [1] http://lampwww.epfl.ch/~linuxsoft/android/android-m5-rc15/docs/reference/android/content/ReceiverCallNotAllowedException.html On Mar 2, 2009, at 9:14 PM, Marco Nelissen wrote: > > You can't use bindService from a broadcast receiver, since the > receiver might not be around long enough for your bind callback to > happen. > > > On Mon, Mar 2, 2009 at 12:11 PM, Mariano Kamp > <mariano.k...@gmail.com> wrote: >> Thank you Jon. >> >> And why do you use startService instead of binding to it, get the >> interface, >> calls something, and get rid of the binding? I was under the >> impression that >> startService would be for something that runs in the background >> like playing >> an audio file. >> >> 2009/3/2 Jon Colverson <jjc1...@gmail.com> >>> >>> On Mar 2, 9:42 am, Mariano Kamp <mariano.k...@gmail.com> wrote: >>>> So how does that work? >>> >>> Here's how nanoTweeter works (slightly abbreviated): >>> >>> The alarm BroadcastReceiver's onReceive() acquires a WakeLock and >>> stores it in a static field so that the Service can access it later. >>> It then starts a Service using Context.startService(). >>> >>> The Service's onStart() creates a Handler for the main thread and >>> then >>> creates and runs a new Thread. That Thread does the important work >>> then releases the WakeLock and calls Service.stopSelf() on the main >>> thread via the Handler that was set up earlier. >>> >>> >>> I pretty much copied the model that the built-in Alarm app uses: >>> >>> http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=tree;h=refs/heads/release-1.0;hb=release-1.0 >>> >>> -- >>> Jon >>> >>> >> >> >>> >> > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---