android.support.v4.content
Class LocalBroadcastManager

java.lang.Object
  extended by android.support.v4.content.LocalBroadcastManager

public class LocalBroadcastManager
extends Object

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 Context.sendBroadcast(android.content.Intent):


Method Summary
static LocalBroadcastManager getInstance(android.content.Context context)
           
 void registerReceiver(android.content.BroadcastReceiver receiver, android.content.IntentFilter filter)
          Register a receive for any local broadcasts that match the given IntentFilter.
 boolean sendBroadcast(android.content.Intent intent)
          Broadcast the given intent to all interested BroadcastReceivers.
 void sendBroadcastSync(android.content.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(android.content.BroadcastReceiver receiver)
          Unregister a previously registered BroadcastReceiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LocalBroadcastManager getInstance(android.content.Context context)

registerReceiver

public void registerReceiver(android.content.BroadcastReceiver receiver,
                             android.content.IntentFilter filter)
Register a receive for any local broadcasts that match the given IntentFilter.

Parameters:
receiver - The BroadcastReceiver to handle the broadcast.
filter - Selects the Intent broadcasts to be received.
See Also:
unregisterReceiver(android.content.BroadcastReceiver)

unregisterReceiver

public void unregisterReceiver(android.content.BroadcastReceiver receiver)
Unregister a previously registered BroadcastReceiver. All filters that have been registered for this BroadcastReceiver will be removed.

Parameters:
receiver - The BroadcastReceiver to unregister.
See Also:
registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)

sendBroadcast

public boolean sendBroadcast(android.content.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 - The Intent to broadcast; all receivers matching this Intent will receive the broadcast.
See Also:
registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)

sendBroadcastSync

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



Copyright © 2013 Marek Kedzierski. All Rights Reserved.