Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do android broadcast receivers consume battery life?

I have two receivers that are listening for android.intent.action.BOOT_COMPLETED and android.intent.action.PACKAGE_REPLACED. I was wondering how much battery life they are causing my phone to consume since they cause my app to constantly run now.

like image 465
ninjasense Avatar asked Dec 28 '10 21:12

ninjasense


People also ask

Does broadcast receiver run in background?

A broadcast receiver will always get notified of a broadcast, regardless of the status of your application. It doesn't matter if your application is currently running, in the background or not running at all.

What is the life cycle of broadcast receivers in Android?

Latest Android Aptitude Question SOLUTION: What is the life cycle of broadcast receivers in android? Options 1) send intent() 2) onRecieve() 3) implicitBroadcast() 4) sendBroadcast(), sendOrderBroadcast(), and sendStickyB.

Why we use broadcast receiver in Android?

Broadcast in android is the system-wide events that can occur when the device starts, when a message is received on the device or when incoming calls are received, or when a device goes to airplane mode, etc. Broadcast Receivers are used to respond to these system-wide events.

Is broadcast receiver deprecated?

What does saving battery have to do with BroadcastReceivers? With Android Nougat, the support for registering three different implicit BroadcastReceivers in your AndroidManifest was removed. With apps targeting Android O, all implicit BroadcastReceivers registered in the manifest (except these) will stop working.


1 Answers

The broadcast receivers themselves will not directly consume much battery life. BOOT_COMPLETED happens once; PACKAGE_REPLACED happens only on an application upgrade. Those probably average one event per day.

Now, if those broadcast receivers do other stuff, such as starting services, that may have significant battery implications...but that is a problem with your services, not with the receivers themselves.

like image 195
CommonsWare Avatar answered Sep 23 '22 04:09

CommonsWare