Context.RegisterReceiver Method

Definition

Overloads

RegisterReceiver(BroadcastReceiver, IntentFilter)

Register a BroadcastReceiver to be run in the main activity thread.

RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags)

Register to receive intent broadcasts, with the receiver optionally being exposed to Instant Apps.

RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler)

Register to receive intent broadcasts, to run in the context of <var>scheduler</var>.

RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ActivityFlags)

Register to receive intent broadcasts, to run in the context of <var>scheduler</var>.

RegisterReceiver(BroadcastReceiver, IntentFilter)

Register a BroadcastReceiver to be run in the main activity thread.

[Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_Handler")]
public abstract Android.Content.Intent? RegisterReceiver (Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter);
[<Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_Handler")>]
abstract member RegisterReceiver : Android.Content.BroadcastReceiver * Android.Content.IntentFilter -> Android.Content.Intent

Parameters

receiver
BroadcastReceiver

The BroadcastReceiver to handle the broadcast.

filter
IntentFilter

Selects the Intent broadcasts to be received.

Returns

Intent

The first sticky intent found that matches <var>filter</var>, or null if there are none.

Attributes

Remarks

Java documentation for android.content.Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to

RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags)

Register to receive intent broadcasts, with the receiver optionally being exposed to Instant Apps.

[Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;I)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_IHandler", ApiSince=26)]
public abstract Android.Content.Intent? RegisterReceiver (Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, Android.Content.ActivityFlags flags);
[<Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;I)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_IHandler", ApiSince=26)>]
abstract member RegisterReceiver : Android.Content.BroadcastReceiver * Android.Content.IntentFilter * Android.Content.ActivityFlags -> Android.Content.Intent

Parameters

receiver
BroadcastReceiver

The BroadcastReceiver to handle the broadcast.

filter
IntentFilter

Selects the Intent broadcasts to be received.

flags
ActivityFlags

Additional options for the receiver. In a future release, either #RECEIVER_EXPORTED or #RECEIVER_NOT_EXPORTED must be specified if the receiver isn't being registered for system broadcasts or an exception will be thrown. If #RECEIVER_EXPORTED is specified, a receiver may additionally specify #RECEIVER_VISIBLE_TO_INSTANT_APPS. For a complete list of system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the Android SDK. If both #RECEIVER_EXPORTED and #RECEIVER_NOT_EXPORTED are specified, an exception will be thrown as well.

Returns

Intent

The first sticky intent found that matches <var>filter</var>, or null if there are none.

Attributes

Remarks

Java documentation for android.content.Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler)

Register to receive intent broadcasts, to run in the context of <var>scheduler</var>.

[Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_Ljava_lang_String_Landroid_os_Handler_Handler")]
public abstract Android.Content.Intent? RegisterReceiver (Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, string? broadcastPermission, Android.OS.Handler? scheduler);
[<Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_Ljava_lang_String_Landroid_os_Handler_Handler")>]
abstract member RegisterReceiver : Android.Content.BroadcastReceiver * Android.Content.IntentFilter * string * Android.OS.Handler -> Android.Content.Intent

Parameters

receiver
BroadcastReceiver

The BroadcastReceiver to handle the broadcast.

filter
IntentFilter

Selects the Intent broadcasts to be received.

broadcastPermission
String

String naming a permissions that a broadcaster must hold in order to send an Intent to you. If null, no permission is required.

scheduler
Handler

Handler identifying the thread that will receive the Intent. If null, the main thread of the process will be used.

Returns

Intent

The first sticky intent found that matches <var>filter</var>, or null if there are none.

Attributes

Remarks

Java documentation for android.content.Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, java.lang.String, android.os.Handler).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to

RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ActivityFlags)

Register to receive intent broadcasts, to run in the context of <var>scheduler</var>.

[Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;I)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_Ljava_lang_String_Landroid_os_Handler_IHandler", ApiSince=26)]
public abstract Android.Content.Intent? RegisterReceiver (Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, string? broadcastPermission, Android.OS.Handler? scheduler, Android.Content.ActivityFlags flags);
[<Android.Runtime.Register("registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;I)Landroid/content/Intent;", "GetRegisterReceiver_Landroid_content_BroadcastReceiver_Landroid_content_IntentFilter_Ljava_lang_String_Landroid_os_Handler_IHandler", ApiSince=26)>]
abstract member RegisterReceiver : Android.Content.BroadcastReceiver * Android.Content.IntentFilter * string * Android.OS.Handler * Android.Content.ActivityFlags -> Android.Content.Intent

Parameters

receiver
BroadcastReceiver

The BroadcastReceiver to handle the broadcast.

filter
IntentFilter

Selects the Intent broadcasts to be received.

broadcastPermission
String

String naming a permissions that a broadcaster must hold in order to send an Intent to you. If null, no permission is required.

scheduler
Handler

Handler identifying the thread that will receive the Intent. If null, the main thread of the process will be used.

flags
ActivityFlags

Additional options for the receiver. In a future release, either #RECEIVER_EXPORTED or #RECEIVER_NOT_EXPORTED must be specified if the receiver isn't being registered for system broadcasts or an exception will be thrown. If #RECEIVER_EXPORTED is specified, a receiver may additionally specify #RECEIVER_VISIBLE_TO_INSTANT_APPS. For a complete list of system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the Android SDK. If both #RECEIVER_EXPORTED and #RECEIVER_NOT_EXPORTED are specified, an exception will be thrown as well.

Returns

Intent

The first sticky intent found that matches <var>filter</var>, or null if there are none.

Attributes

Remarks

Java documentation for android.content.Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, java.lang.String, android.os.Handler, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to