2

In this tutorial a class derives from BroadcastReceiver. It then receives messages. How? This is just a definition of a class, not an instance of it!

And after we figure that out - how do we prevent this from happening so that we can use this class with a LocalBroadcastManager, limiting it to the app only? (Not with the same exact case as in the tutorial, of course, because that's a message that's not from the app.)

ispiro
  • 26,556
  • 38
  • 136
  • 291

1 Answers1

5

When you use annotations like [Service] and [BroadcastReceiver] etc, the Xamarin.Android compiler automatically adds the required sections into the generated AndroidManifest.xml, which in case of the [BroadcastReceiver] it starts working because of the [IntentFilter].

You can see generated manifest at obj\Debug\AndroidManifest.xml

Rafael Steil
  • 4,538
  • 4
  • 25
  • 30
  • Thanks. So how do we prevent this from happening if we want to use a `LocalBroadcastManager`? – ispiro Feb 02 '17 at 18:28
  • OK. Never mind. I got it. Just supply the IntentFilter by code with the LocalBroadcastManager, I assume. – ispiro Feb 02 '17 at 18:30