Package com.batch.android.compat
Class LocalBroadcastManager
- java.lang.Object
-
- com.batch.android.compat.LocalBroadcastManager
-
public class LocalBroadcastManager extends java.lang.ObjectHelper 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 withContext.sendBroadcast(android.content.Intent):- You know that the data you are broadcasting won't leave your app, so don't need to worry about leaking private data.
- It is not possible for other applications to send these broadcasts to your app, so you don't need to worry about having security holes they can exploit.
- It is more efficient than sending a global broadcast through the system.
-
-
Constructor Summary
Constructors Constructor Description LocalBroadcastManager(android.content.Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidregisterReceiver(android.content.BroadcastReceiver receiver, android.content.IntentFilter filter)Register a receive for any local broadcasts that match the given IntentFilter.booleansendBroadcast(android.content.Intent intent)Broadcast the given intent to all interested BroadcastReceivers.voidsendBroadcastSync(android.content.Intent intent)LikesendBroadcast(Intent), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.voidunregisterReceiver(android.content.BroadcastReceiver receiver)Unregister a previously registered BroadcastReceiver.
-
-
-
Method Detail
-
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)
LikesendBroadcast(Intent), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.
-
-