BroadcastOptions
public
class
BroadcastOptions
extends Object
| java.lang.Object | |
| ↳ | android.app.BroadcastOptions |
Helper class for building an options Bundle that can be used with
Context.sendBroadcast(Intent) and related methods.
Summary
Public methods | |
|---|---|
boolean
|
isShareIdentityEnabled()
Returns whether the broadcasting app has opted-in to sharing its identity with the receiver. |
static
BroadcastOptions
|
makeBasic()
Creates a basic |
BroadcastOptions
|
setShareIdentityEnabled(boolean shareIdentityEnabled)
Sets whether the identity of the broadcasting app should be shared with all receivers that will receive this broadcast. |
Bundle
|
toBundle()
Returns the created options as a Bundle, which can be passed to
|
Inherited methods | |
|---|---|
Public methods
isShareIdentityEnabled
public boolean isShareIdentityEnabled ()
Returns whether the broadcasting app has opted-in to sharing its identity with the receiver.
| Returns | |
|---|---|
boolean |
true if the broadcasting app has opted in to sharing its identity |
makeBasic
public static BroadcastOptions makeBasic ()
Creates a basic BroadcastOptions with no options initially set.
| Returns | |
|---|---|
BroadcastOptions |
an instance of BroadcastOptions against which options can be set
This value cannot be null. |
setShareIdentityEnabled
public BroadcastOptions setShareIdentityEnabled (boolean shareIdentityEnabled)
Sets whether the identity of the broadcasting app should be shared with all receivers that will receive this broadcast.
Use this option when broadcasting to a receiver that needs to know the identity of the
broadcaster; with this set to true, the receiver will have access to the broadcasting
app's package name and uid.
Defaults to false if not set.
| Parameters | |
|---|---|
shareIdentityEnabled |
boolean: whether the broadcasting app's identity should be shared with the
receiver |
| Returns | |
|---|---|
BroadcastOptions |
this BroadcastOptions instance
This value cannot be null. |
toBundle
public Bundle toBundle ()
Returns the created options as a Bundle, which can be passed to
Context.sendBroadcast(Intent) and related methods.
Note that the returned Bundle is still owned by the BroadcastOptions
object; you must not modify it, but can supply it to the sendBroadcast
methods that take an options Bundle.
| Returns | |
|---|---|
Bundle |
This value cannot be null. |
| Throws | |
|---|---|
IllegalStateException |
if the broadcast option values are inconsistent. For example, if the delivery group policy is specified as "MERGED" but no extras merger is supplied. |