1

I have a broadcast receiver defined in the XML manifest. There are events which another app of mine is sending via the broadcast to the receiver. I also have an Application object defined in the manifest as well. When an activity is fired up, the application on create method is triggered. However, the same is not true for the broadcast receiver. Is there any way to wire up the broadcast reciever such that it is "part of" the application and will fire up that object's oncreate method?

Ben
  • 16,124
  • 22
  • 77
  • 122
  • Why do you need the Application object? and the context object passed by `onReceive` isn't an application object? – Dan S Jun 02 '12 at 00:08
  • "However, the same is not true for the broadcast receiver" -- please post a sample app demonstrating this behavior. Your process, when started, will first create instances of any `ContentProviders` that you have defined in your manifest, then will create an instance of the `Application` object, and only then should start creating and invoking lifecycle methods on components like a `BroadcastReceiver`. If you have a sample project demonstrating that this is not working, post it, and I'll take a look at it. – CommonsWare Jun 02 '12 at 11:04
  • it looks like I was mistaken about this. This is related to the fact that the user has to start the app for the first time in order for the Broadcast Receiver to get triggered. kind of annoying, but i guess there's not much i can do about it... – Ben Jun 03 '12 at 19:55
  • btw, this is related to http://stackoverflow.com/questions/9952562/broadcast-receiver-not-working-in-ics-if-the-app-is-not-started-atleast-once/9955247#comment14188232_9955247 – Ben Jun 04 '12 at 18:09

0 Answers0