user1928346
user1928346

Reputation: 513

Xamarin: BroadcastReceiver not receiving when the app is not running

I'm new to BroadcastReceiver and I'm currently trying it out. From my understanding in Xamarin we'll only need to decorate our receiver subclass with the BroadcastReceiver attribute and Xamarin will generate the necessary entries in the manifest. This is what I have currently:

[BroadcastReceiver(Enabled = true, Exported = true)]
[IntentFilter(new[] { "myaction" })]
class MyReceiver : BroadcastReceiver
{
}

Everything works fine when I'm sending the broadcast within the application itself OR when I send a broadcast from other application while this application is running. The thing is when I'm not running this application and if I attempt to send broadcast from other application (using the correct intent filter) I'll not be able to receive the broadcast.

I've done a little bit reading here on this issue and it seems that for native Java we'll need to explicitly declare / define BroadcastReceiver in the manifest itself for it to be able to receive broadcast even when it is not running. From my understanding this is not required for Xamarin so I'm kind of stuck right now. Do you guys have any insight on this?

Additional info:

Upvotes: 4

Views: 1324

Answers (1)

dinostroza
dinostroza

Reputation: 103

you have to declare it from within a Service. The reason is given here in Process Lifecycle section.

Regards.

Upvotes: 1

Related Questions