Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BroadcastReceiver vs Service

Well, in android, what is the difference between doing something in broadcastReceiver and calling another service in broadcastReceiver? I think they both run in background,right?

Actually, what I what to do is:

In certain time of everyday, download the user event(eg: 9:00 am eat breakfast) from database, and set up the AlarmManager to show notification about the event.

Now I set up a alarm manager to do the above task. And I am puzzled should I directly accomplish this in BroadcastReceiver or call service in BroadcastReceiver to accomplish this.

Thank You.

like image 839
Bear Avatar asked Sep 18 '11 08:09

Bear


1 Answers

You should do as LITTLE processing in a BroadcastReceiver as possible because (quoting from the Android Blog)

When handling a broadcast, the application is given a fixed set of time (currently 10 seconds) in which to do its work. If it doesn't complete in that time, the application is considered to be misbehaving, and its process immediately tossed into the background state to be killed for memory if needed.

like image 153
D-Dᴙum Avatar answered Oct 27 '22 03:10

D-Dᴙum