Android.Content.BroadcastReceiver.OnReceive Method
This method is called when the BroadcastReceiver is receiving an Intent broadcast.

Syntax

[Android.Runtime.Register("onReceive", "(Landroid/content/Context;Landroid/content/Intent;)V", "GetOnReceive_Landroid_content_Context_Landroid_content_Intent_Handler")]
public abstract void OnReceive (Context context, Intent intent)

Parameters

context
The Context in which the receiver is running.
intent
The Intent being received.

Remarks

This method is called when the BroadcastReceiver is receiving an Intent broadcast. During this time you can use the other methods on BroadcastReceiver to view/modify the current result values. This method is always called within the main thread of its process, unless you explicitly asked for it to be scheduled on a different thread using Context.RegisterReceiver(BroadcastReceiver, Android.Content.IntentFilter, Android.Content.IntentFilter, Android.Content.IntentFilter). When it runs on the main thread you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive().

If this BroadcastReceiver was launched through a <receiver> tag, then the object is no longer alive after returning from this function. This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use Context.StartService(Intent) instead of Context.BindService(Intent, Android.Content.IServiceConnection, Android.Content.IServiceConnection). If you wish to interact with a service that is already running, you can use BroadcastReceiver.PeekService(Context, Android.Content.Intent).

The Intent filters used in Context.RegisterReceiver(BroadcastReceiver, Android.Content.IntentFilter) and in application manifests are not guaranteed to be exclusive. They are hints to the operating system about how to find suitable recipients. It is possible for senders to force delivery to specific recipients, bypassing filter resolution. For this reason, BroadcastReceiver.OnReceive(Context, Android.Content.Intent) implementations should respond only to known actions, ignoring any unexpected Intents that they may receive.

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1