# LocalBroadcastManager

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:localbroadcastmanager:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#)  

# LocalBroadcastManager

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
LocalBroadcastManager
`  
`

extends Object


``


`

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

<br />

*** ** * ** ***

Helper to register for and send broadcasts of Intents to local objects within your process. This has a number of advantages over sending global broadcasts with[sendBroadcast(Intent)](https://developer.android.com/reference/android/content/Context.html#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.

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                                                                                                                           ||
|-----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[LocalBroadcastManager](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager) | ` `[getInstance](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#getInstance(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) `                                                                                                                                                                                                                                                                                             |
| ` void`                                                                                                                     | ` `[registerReceiver](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter))`(`[BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html)` receiver, `[IntentFilter](https://developer.android.com/reference/android/content/IntentFilter.html)` filter) ` Register a receive for any local broadcasts that match the given IntentFilter.                                   |
| ` boolean`                                                                                                                  | ` `[sendBroadcast](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#sendBroadcast(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` Broadcast the given intent to all interested BroadcastReceivers.                                                                                                                                                                                                                            |
| ` void`                                                                                                                     | ` `[sendBroadcastSync](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#sendBroadcastSync(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` Like[sendBroadcast(Intent)](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#sendBroadcast(android.content.Intent)), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning. |
| ` void`                                                                                                                     | ` `[unregisterReceiver](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#unregisterReceiver(android.content.BroadcastReceiver))`(`[BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html)` receiver) ` Unregister a previously registered BroadcastReceiver.                                                                                                                                                                                          |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### getInstance

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
LocalBroadcastManager getInstance (Context context)
```

<br />

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

|                                                          Returns                                                          ||
|-------------------------------------------------------------------------------------------------------------------|--------|
| [LocalBroadcastManager](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager) | <br /> |

### registerReceiver

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void registerReceiver (BroadcastReceiver receiver, 
                IntentFilter filter)
```

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

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `receiver` | `BroadcastReceiver`: The BroadcastReceiver to handle the broadcast. <br /> |
| `filter`   | `IntentFilter`: Selects the Intent broadcasts to be received. <br />       |

**See also:**

- [unregisterReceiver(BroadcastReceiver)](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#unregisterReceiver(android.content.BroadcastReceiver))  

### sendBroadcast

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                                                     Parameters                                                     ||
|----------|----------------------------------------------------------------------------------------------------------|
| `intent` | `Intent`: The Intent to broadcast; all receivers matching this Intent will receive the broadcast. <br /> |

|                                                                                                                Returns                                                                                                                 ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | Returns true if the intent has been scheduled for delivery to one or more broadcast receivers. (Note that delivery may not ultimately take place if one of those receivers is unregistered before it is dispatched.) <br /> |

**See also:**

- [registerReceiver(BroadcastReceiver, IntentFilter)](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter))  

### sendBroadcastSync

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void sendBroadcastSync (Intent intent)
```

Like[sendBroadcast(Intent)](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#sendBroadcast(android.content.Intent)), but if there are any receivers for the Intent this function will block and immediately dispatch them before returning.

<br />

|        Parameters         ||
|----------|-----------------|
| `intent` | `Intent` <br /> |

### unregisterReceiver

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void unregisterReceiver (BroadcastReceiver receiver)
```

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

<br />

|                                  Parameters                                  ||
|------------|------------------------------------------------------------------|
| `receiver` | `BroadcastReceiver`: The BroadcastReceiver to unregister. <br /> |

**See also:**

- [registerReceiver(BroadcastReceiver, IntentFilter)](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter))  
-

  ## Interfaces

  - [Loader.OnLoadCanceledListener](https://developer.android.com/reference/android/support/v4/content/Loader.OnLoadCanceledListener)
  - [Loader.OnLoadCompleteListener](https://developer.android.com/reference/android/support/v4/content/Loader.OnLoadCompleteListener)
-

  ## Classes

  - [AsyncTaskLoader](https://developer.android.com/reference/android/support/v4/content/AsyncTaskLoader)
  - [ContentResolverCompat](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat)
  - [ContextCompat](https://developer.android.com/reference/android/support/v4/content/ContextCompat)
  - [CursorLoader](https://developer.android.com/reference/android/support/v4/content/CursorLoader)
  - [FileProvider](https://developer.android.com/reference/android/support/v4/content/FileProvider)
  - [IntentCompat](https://developer.android.com/reference/android/support/v4/content/IntentCompat)
  - [Loader](https://developer.android.com/reference/android/support/v4/content/Loader)
  - [Loader.ForceLoadContentObserver](https://developer.android.com/reference/android/support/v4/content/Loader.ForceLoadContentObserver)
  - [LocalBroadcastManager](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager)
  - [MimeTypeFilter](https://developer.android.com/reference/android/support/v4/content/MimeTypeFilter)
  - [PermissionChecker](https://developer.android.com/reference/android/support/v4/content/PermissionChecker)
  - [SharedPreferencesCompat](https://developer.android.com/reference/android/support/v4/content/SharedPreferencesCompat)
  - [SharedPreferencesCompat.EditorCompat](https://developer.android.com/reference/android/support/v4/content/SharedPreferencesCompat.EditorCompat)
  - [WakefulBroadcastReceiver](https://developer.android.com/reference/android/support/v4/content/WakefulBroadcastReceiver)