My code below doesn't work on androind 8.0+, but works before 8.0. Thus, it seems it is treated as an implicit broadcast.

 [BroadcastReceiver(Enabled = true, Exported = true)]
    [IntentFilter(new[] { "" })]
    public class MySampleBroadcastReceiver : BroadcastReceiver
        public override void OnReceive(Context context, Intent intent)
            String value = intent.GetStringExtra("key");

     var intent = new Intent("");
            intent.PutExtra("key", "MySampleBroadcastReceiver");

I want to know what is defined as Explicit broadcast or Implicit broadcast?

Because I need the app to receive message when it is not running, like below:

The primary difference between the manifest-registered receiver and the context-registered receiver is that a context-registered receiver will only respond to broadcasts while an application is running, while a manifest-registered receiver can respond to broadcasts even though the app may not be running.

Android identifies two types of broadcasts:

Explicit broadcast – These types of broadcasts target a specific application. The most common use of an explicit broadcast is to start an Activity. An example of an explicit broadcast when an app needs to dial a phone number; it will dispatch an Intent that targets the Phone app on Android and pass along the phone number to be dialed. Android will then route the intent to the Phone app.

Implicit broadcast – These broadcasts are dispatched to all apps on the device. An example of an implicit broadcast is the ACTION_POWER_CONNECTED intent. This intent is published each time Android detects that the battery on the device is charging. Android will route this intent to all apps that have registered for this event.


Please correct me if I am wrong:

Based on the description below, MySampleBroadcastReceiver above is manifest-registered receiver, so it should be able to receive message. But it is not even working. I have to change it to dynamic registration.

An intent filter is used to register a broadcast receiver so that Android can properly route messages. The intent filter can be specified at runtime (this is sometimes referred to as a context-registered receiver or as dynamic registration) or it can be statically defined in the Android Manifest (a manifest-registered receiver).

1 Answers

Leon Lu - MSFT On

What is defined as Explicit broadcast or Implicit broadcast?

Explicit broadcast

The sent Intent is a broadcast that shows the Intent. By specifying the name of the Intent component, it is generally used to know the name of the target component, to call the following method. The intent is clear, specifying which component is to be activated, which is typically implemented inside the same application.

new Intent(A.this,B.class)

Implicit broadcast

It is implemented by Intent Filter, which is generally used without explicitly indicating the name of the target component. The Android system will handle this intent by finding the most appropriate component based on the action, category, data (URI and data type) set in the implicit intent. Generally used between different applications

Your code is Explicit broadcast

I need the app to receive message when it is not running

Based on my research, it cannot be achievd in Explicit broadcast, If application is closed, Explicit broadcast will be closed.

If you want to achieve application receive messages from server and it will not closed by the Android system, I suggest you to Start the service in the foreground like this link. How to create service doing work at period time in Xamarin.Forms?