Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why some broadcast receiver can only be registered through either Code or AndroidManifest

Some broadcast receivers only work if they are registered via code rather than defined in AndroidManifest.

For example:

SCREEN_ON, SCREEN_OFF

These actions will only work with receivers registered in code. No errors happen if they are registered in the manifest, but they never get called either.

What are the reasons for this undocumented behavior? Security?

like image 969
N Sharma Avatar asked Mar 25 '14 05:03

N Sharma


1 Answers

I don't think there is a security issue around this.

Manifest defined broadcast receivers are registered and can receive intents even if the application is not in memory. The opposite doesn't occur.

It could be a performance issue because registering a receiver for this type of events, may drain the user battery.

Main difference between Manifest and Programmatic registering of BroadcastReceiver

like image 70
Diogo Bento Avatar answered Sep 23 '22 21:09

Diogo Bento