Most visited

Recently visited

LocalBroadcastManager

public final class LocalBroadcastManager
extends Object

java.lang.Object
   ↳ android.support.v4.content.LocalBroadcastManager


Helper to register for and send broadcasts of Intents to local objects within your process. This is has a number of advantages over sending global broadcasts with sendBroadcast(Intent):

Summary

Public methods

static LocalBroadcastManager getInstance(Context context)
void registerReceiver(BroadcastReceiver receiver, IntentFilter filter)

Register a receive for any local broadcasts that match the given IntentFilter.

boolean sendBroadcast(Intent intent)

Broadcast the given intent to all interested BroadcastReceivers.

void sendBroadcastSync(Intent intent)

Like sendBroadcast(Intent), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.

void unregisterReceiver(BroadcastReceiver receiver)

Unregister a previously registered BroadcastReceiver.

Inherited methods

From class java.lang.Object

Public methods

getInstance

LocalBroadcastManager getInstance (Context context)

Parameters
context Context
Returns
LocalBroadcastManager

registerReceiver

void registerReceiver (BroadcastReceiver receiver, 
                IntentFilter filter)

Register a receive for any local broadcasts that match the given IntentFilter.

Parameters
receiver BroadcastReceiver: The BroadcastReceiver to handle the broadcast.
filter IntentFilter: Selects the Intent broadcasts to be received.

See also:

sendBroadcast

boolean sendBroadcast (Intent intent)

Broadcast the given intent to all interested BroadcastReceivers. This call is asynchronous; it returns immediately, and you will continue executing while the receivers are run.

Parameters
intent Intent: The Intent to broadcast; all receivers matching this Intent will receive the broadcast.
Returns
boolean

See also:

sendBroadcastSync

void sendBroadcastSync (Intent intent)

Like sendBroadcast(Intent), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.

Parameters
intent Intent

unregisterReceiver

void unregisterReceiver (BroadcastReceiver receiver)

Unregister a previously registered BroadcastReceiver. All filters that have been registered for this BroadcastReceiver will be removed.

Parameters
receiver BroadcastReceiver: The BroadcastReceiver to unregister.

See also:

Hooray!