Compartilhar via


Context.SendStickyOrderedBroadcast Method

Definition

Caution

deprecated

Version of #sendStickyBroadcast that allows you to receive data back from the broadcast.

[Android.Runtime.Register("sendStickyOrderedBroadcast", "(Landroid/content/Intent;Landroid/content/BroadcastReceiver;Landroid/os/Handler;ILjava/lang/String;Landroid/os/Bundle;)V", "GetSendStickyOrderedBroadcast_Landroid_content_Intent_Landroid_content_BroadcastReceiver_Landroid_os_Handler_ILjava_lang_String_Landroid_os_Bundle_Handler")]
[Android.Runtime.RequiresPermission("android.permission.BROADCAST_STICKY")]
[System.Obsolete("deprecated")]
public abstract void SendStickyOrderedBroadcast (Android.Content.Intent? intent, Android.Content.BroadcastReceiver? resultReceiver, Android.OS.Handler? scheduler, Android.App.Result initialCode, string? initialData, Android.OS.Bundle? initialExtras);
[<Android.Runtime.Register("sendStickyOrderedBroadcast", "(Landroid/content/Intent;Landroid/content/BroadcastReceiver;Landroid/os/Handler;ILjava/lang/String;Landroid/os/Bundle;)V", "GetSendStickyOrderedBroadcast_Landroid_content_Intent_Landroid_content_BroadcastReceiver_Landroid_os_Handler_ILjava_lang_String_Landroid_os_Bundle_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.BROADCAST_STICKY")>]
[<System.Obsolete("deprecated")>]
abstract member SendStickyOrderedBroadcast : Android.Content.Intent * Android.Content.BroadcastReceiver * Android.OS.Handler * Android.App.Result * string * Android.OS.Bundle -> unit

Parameters

intent
Intent

The Intent to broadcast; all receivers matching this Intent will receive the broadcast.

resultReceiver
BroadcastReceiver

Your own BroadcastReceiver to treat as the final receiver of the broadcast.

scheduler
Handler

A custom Handler with which to schedule the resultReceiver callback; if null it will be scheduled in the Context's main thread.

initialCode
Result

An initial value for the result code. Often Activity.RESULT_OK.

initialData
String

An initial value for the result data. Often null.

initialExtras
Bundle

An initial value for the result extras. Often null.

Attributes

Remarks

Version of #sendStickyBroadcast that allows you to receive data back from the broadcast. This is accomplished by supplying your own BroadcastReceiver when calling, which will be treated as a final receiver at the end of the broadcast -- its BroadcastReceiver#onReceive method will be called with the result values collected from the other receivers. The broadcast will be serialized in the same way as calling #sendOrderedBroadcast(Intent, String).

Like #sendBroadcast(Intent), this method is asynchronous; it will return before resultReceiver.onReceive() is called. Note that the sticky data stored is only the data you initially supply to the broadcast, not the result of any changes made by the receivers.

See BroadcastReceiver for more information on Intent broadcasts.

This member is deprecated. Sticky broadcasts should not be used. They provide no security (anyone can access them), no protection (anyone can modify them), and many other problems. The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> has changed, with another mechanism for apps to retrieve the current value whenever desired.

Java documentation for android.content.Context.sendStickyOrderedBroadcast(android.content.Intent, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle).

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

See also

  • SendBroadcast(Intent)
  • <xref:Android.Content.Context.SendBroadcast(Android.Content.Intent%2c+System.String)>
  • <xref:Android.Content.Context.SendOrderedBroadcast(Android.Content.Intent%2c+System.String)>
  • SendStickyBroadcast(Intent)
  • BroadcastReceiver
  • <xref:Android.Content.Context.RegisterReceiver(Android.Content.BroadcastReceiver%2c+Android.Content.IntentFilter)>