Sunday, June 5, 2011

Re: [android-developers] Repeating alarm service

On Sun, Jun 5, 2011 at 9:27 AM, Simon Platten
<simonaplatten@googlemail.com> wrote:
> I think I may have fixed it, I looked around for some information on
> BroadcastReciever 'onRecieve' routines.  I suspected it was that I was
> spending to much time in this routine, but I couldn't find anything to back
> this up.
>
> What I have done now is to create a worker thread when the onRecieve is
> called, this allows the onRecieve to return almost instantly and so far,
> since doing this I haven't had any problems.

A manifest-registered BroadcastReceiver cannot safely fork threads.
Once onReceive() is done, Android can terminate the process at any
time, and it might well do that before your thread is finished.

The typical pattern for a manifest-registered BroadcastReceiver that
is doing any significant work is for it to call startService() on an
IntentService, with the IntentService doing the "real work". If the
alarm for your AlarmManager is a _WAKEUP alarm, you will also need to
think about WakeLocks, perhaps using my WakefulIntentService or
something else following that pattern:

https://github.com/commonsguy/cwac-wakeful

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 3.0 Programming Books: http://commonsware.com/books

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate