0

I'd like to send broadcast and receive it only if receiver registered in code with registerReceiver(), like ACTION_SCREEN_OFF or ACTION_SCREEN_ON. I'd like to forbid registering receiver in AndroidManifest.xml. Is it possible?

EDIT

Is it possible to send broadcast which can be received ONLY if broadcastReceiver is registered with registerReceiver()?

mehdi lotfi
  • 11,194
  • 18
  • 82
  • 128
  • could you clarify forbid registering receiver in manifest? – Raghunandan Sep 19 '13 at 11:35
  • I mean the follows: i send broadcast from _application1_. I has _application2_ where broadcastReceiver registered in manifest and _application3_ where broadcastReceiver registered in code. I want's to receive broadcast in _application3_ and **NOT** in _application2_. – Vasily Galuzin Sep 19 '13 at 11:57
  • Maybe this could help you: - [Broadcast Receiver Register in Manifest vs. Activity](http://stackoverflow.com/questions/10876015/broadcast-receiver-register-in-manifest-vs-activity) - [Is it better code practice to register a receiver in manifest or in code?](http://stackoverflow.com/questions/7880741/is-it-better-code-practice-to-register-a-receiver-in-manifest-or-in-code) – Diego Palomar Sep 19 '13 at 11:33
  • Thanks, but I saw these links, but unfortunately they didn't help me. – Vasily Galuzin Sep 19 '13 at 11:46

1 Answers1

-1

Yes you can do it by programatically also.

Please have a look into this registering a broadcast receiver programatically.

http://code4reference.com/2012/09/register-unregiste-broadcast-receiver-part/

android_dev
  • 1,477
  • 12
  • 18
  • The OP knows it's possible to do it both ways. That is not what he asked. Read the question more carefully. – NickT Sep 19 '13 at 11:33