Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/os/RemoteCallbackList#nestedclasses) \| [Constants](https://developer.android.com/reference/android/os/RemoteCallbackList#constants) \| [Ctors](https://developer.android.com/reference/android/os/RemoteCallbackList#pubctors) \| [Methods](https://developer.android.com/reference/android/os/RemoteCallbackList#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/os/RemoteCallbackList#inhmethods)

# RemoteCallbackList

*** ** * ** ***


`
public


class
RemoteCallbackList
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.RemoteCallbackList\<E extends [android.os.IInterface](https://developer.android.com/reference/android/os/IInterface)\> |

<br />

*** ** * ** ***

Takes care of the grunt work of maintaining a list of remote interfaces,
typically for the use of performing callbacks from a
`https://developer.android.com/reference/android/app/Service` to its clients. In particular, this:

- Keeps track of a set of registered `https://developer.android.com/reference/android/os/IInterface` objects, taking care to identify them through their underlying unique `https://developer.android.com/reference/android/os/IBinder` (by calling `https://developer.android.com/reference/android/os/IInterface#asBinder()`.
- Attaches a `https://developer.android.com/reference/android/os/IBinder.DeathRecipient` to each registered interface, so that it can be cleaned out of the list if its process goes away.
- Performs locking of the underlying list of interfaces to deal with multithreaded incoming calls, and a thread-safe way to iterate over a snapshot of the list without holding its lock.

To use this class, simply create a single instance along with your
service, and call its `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)` and `https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)` methods
as client register and unregister with your service. To call back on to
the registered clients, use `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`,
`https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)`, and `https://developer.android.com/reference/android/os/RemoteCallbackList#finishBroadcast()`.

If a registered interface's process goes away, this class will take
care of automatically removing it from the list. If you want to do
additional work in this situation, you can create a subclass that
implements the `https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E)` method.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/os/RemoteCallbackList.Builder<E extends https://developer.android.com/reference/android/os/IInterface>` Builder for `https://developer.android.com/reference/android/os/RemoteCallbackList`. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_DROP` When the callback recipient's process is frozen, callbacks are suppressed as if they never happened. |
| `int` | `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_ALL` When the callback recipient's process is frozen, callbacks are enqueued so they're invoked after the recipient is unfrozen. |
| `int` | `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT` When the callback recipient's process is frozen, only the most recent callback is enqueued, which is later invoked after the recipient is unfrozen. |
| `int` | `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET` Callbacks are invoked immediately regardless of the frozen state of the target process. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/os/RemoteCallbackList#RemoteCallbackList()() ` Creates a RemoteCallbackList with `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET`. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()() ` Use `https://developer.android.com/reference/android/os/RemoteCallbackList#broadcast(java.util.function.Consumer<E>)` instead to ensure proper handling of frozen processes. |
| ` void` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#broadcast(java.util.function.Consumer<E>)(https://developer.android.com/reference/java/util/function/Consumer<E> callback) ` Performs `callback` on each registered interface. |
| ` void` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#finishBroadcast()() ` Clean up the state of a broadcast previously initiated by calling `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`. |
| ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastCookie(int)(int index) ` Retrieve the cookie associated with the item returned by `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)`. |
| ` E` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)(int index) ` Retrieve an item in the active broadcast that was previously started with `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`. |
| ` https://developer.android.com/reference/java/util/concurrent/Executor` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getExecutor()() ` Returns the executor used when invoking callbacks asynchronously. |
| ` int` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getFrozenCalleePolicy()() ` Returns the frozen callee policy. |
| ` int` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getMaxQueueSize()() ` Returns the max queue size. |
| ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getRegisteredCallbackCookie(int)(int index) ` Return any cookie associated with a currently registered interface. |
| ` int` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getRegisteredCallbackCount()() ` Returns the number of registered interfaces. |
| ` E` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#getRegisteredCallbackItem(int)(int index) ` Return a currently registered interface. |
| ` void` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#kill()() ` Disable this interface list. |
| ` void` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E,%20java.lang.Object)(E callbackInterface, https://developer.android.com/reference/java/lang/Object cookie) ` Called when the process hosting an interface in the list has gone away. |
| ` void` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E)(E callbackInterface) ` Old version of `https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E,%20java.lang.Object)` that does not provide a cookie. |
| ` boolean` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#register(E,%20java.lang.Object)(E callbackInterface, https://developer.android.com/reference/java/lang/Object cookie) ` Add a new interface to the list. |
| ` boolean` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)(E callbackInterface) ` Simple version of `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E,%20java.lang.Object)` that does not take a cookie object. |
| ` boolean` | ` https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)(E callbackInterface) ` Remove from the list an interface that was previously added with `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)`. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Constants

### FROZEN_CALLEE_POLICY_DROP

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FROZEN_CALLEE_POLICY_DROP
```

When the callback recipient's process is frozen, callbacks are suppressed as if they never
happened.

This could be useful in the case where the recipient wishes to react to callbacks only when
they occur while the recipient is not frozen. For example, certain network events are only
worth responding to if the response can be immediate. Another example is recipients having
another way of getting the latest state once it's unfrozen. Therefore there is no need to
save callbacks that happened while the recipient was frozen.

<br />

Constant Value:

3
(0x00000003)


### FROZEN_CALLEE_POLICY_ENQUEUE_ALL

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FROZEN_CALLEE_POLICY_ENQUEUE_ALL
```

When the callback recipient's process is frozen, callbacks are enqueued so they're invoked
after the recipient is unfrozen.

This is commonly used when the recipient wants to receive all callbacks without losing any
history, e.g. the recipient maintains a running count of events that occurred.

Queued callbacks are invoked in the order they were originally broadcasted.

<br />

Constant Value:

1
(0x00000001)


### FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT
```

When the callback recipient's process is frozen, only the most recent callback is enqueued,
which is later invoked after the recipient is unfrozen.

This can be used when only the most recent state matters, for instance when clients are
listening to screen brightness changes.

<br />

Constant Value:

2
(0x00000002)


### FROZEN_CALLEE_POLICY_UNSET

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FROZEN_CALLEE_POLICY_UNSET
```

Callbacks are invoked immediately regardless of the frozen state of the target process.

Not recommended. Only exists for backward-compatibility. This represents the behavior up to
SDK 35. Starting with SDK 36, clients should set a policy to govern callback invocations when
recipients are frozen.

<br />

Constant Value:

0
(0x00000000)


## Public constructors

### RemoteCallbackList

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RemoteCallbackList ()
```

Creates a RemoteCallbackList with `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET`. This is equivalent to

```
new RemoteCallbackList.Build(RemoteCallbackList.FROZEN_CALLEE_POLICY_UNSET).build()
```

<br />

<br />

## Public methods

### beginBroadcast

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int beginBroadcast ()
```

Use `https://developer.android.com/reference/android/os/RemoteCallbackList#broadcast(java.util.function.Consumer<E>)` instead to ensure proper handling of frozen processes.

Prepare to start making calls to the currently registered interfaces.
This creates a copy of the interface list, which you can retrieve items
from using `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)`. Note that only one broadcast can
be active at a time, so you must be sure to always call this from the
same thread (usually by scheduling with `https://developer.android.com/reference/android/os/Handler`) or
do your own synchronization. You must call `https://developer.android.com/reference/android/os/RemoteCallbackList#finishBroadcast()`
when done.

A typical loop delivering a broadcast looks like this:

```
int i = interfaces.beginBroadcast();
while (i > 0) {
    i--;
    try {
        interfaces.getBroadcastItem(i).somethingHappened();
    } catch (RemoteException e) {
        // The RemoteCallbackList will take care of removing
        // the dead object for us.
    }
}
interfaces.finishBroadcast();
```
Note that this method is only supported for `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET`. For other policies use `https://developer.android.com/reference/android/os/RemoteCallbackList#broadcast(java.util.function.Consumer<E>)` instead.

<br />

<br />

| Returns ||
|---|---|
| `int` | Returns the number of interfaces in the broadcast, to be used with `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)` to determine the range of indices you can supply. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if an frozen callee policy is set. |

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)`
- `https://developer.android.com/reference/android/os/RemoteCallbackList#finishBroadcast()`

### broadcast

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void broadcast (Consumer<E> callback)
```

Performs `callback` on each registered interface.

This is equivalent to `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`, followed by iterating over the
items using `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)` and then `https://developer.android.com/reference/android/os/RemoteCallbackList#finishBroadcast()`,
except that this method supports frozen callee policies.

<br />

| Parameters ||
|---|---|
| `callback` | `Consumer`: This value cannot be `null`. <br /> |

### finishBroadcast

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void finishBroadcast ()
```

Clean up the state of a broadcast previously initiated by calling
`https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`. This must always be called when you are done
with a broadcast.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`

### getBroadcastCookie

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Object getBroadcastCookie (int index)
```

Retrieve the cookie associated with the item
returned by `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)`.

<br />

| Parameters ||
|---|---|
| `index` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Object` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)`

### getBroadcastItem

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public E getBroadcastItem (int index)
```

Retrieve an item in the active broadcast that was previously started
with `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`. This can *only* be called after
the broadcast is started, and its data is no longer valid after
calling `https://developer.android.com/reference/android/os/RemoteCallbackList#finishBroadcast()`.

Note that it is possible for the process of one of the returned
interfaces to go away before you call it, so you will need to catch
`https://developer.android.com/reference/android/os/RemoteException` when calling on to the returned object.
The interface list itself, however, will take care of unregistering
these objects once it detects that it is no longer valid, so you can
handle such an exception by simply ignoring it.

<br />

| Parameters ||
|---|---|
| `index` | `int`: Which of the registered interfaces you would like to retrieve. Ranges from 0 to `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`-1, inclusive. <br /> |

| Returns ||
|---|---|
| `E` | Returns the interface that you can call. This will always be non-null. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()`

### getExecutor

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Executor getExecutor ()
```

Returns the executor used when invoking callbacks asynchronously.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/Executor` | The executor. This value may be `null`. <br /> |

### getFrozenCalleePolicy

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getFrozenCalleePolicy ()
```

Returns the frozen callee policy.

Note that if the list silently fell back to `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET`
behavior (e.g., due to lack of kernel support), this method will still return the
originally configured policy.

<br />

<br />

| Returns ||
|---|---|
| `int` | The frozen callee policy. Value is one of the following: - `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET` - `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_ALL` - `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT` - `https://developer.android.com/reference/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_DROP` |

### getMaxQueueSize

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getMaxQueueSize ()
```

Returns the max queue size.

<br />

| Returns ||
|---|---|
| `int` | The max queue size. <br /> |

### getRegisteredCallbackCookie

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Object getRegisteredCallbackCookie (int index)
```

Return any cookie associated with a currently registered interface. Note that this is
*not* the same as `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastCookie(int)` and should not be used
interchangeably with it. This method returns the current cookie registered at the given
index, not the current broadcast state. This means that it is not itself thread-safe:
any call to `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)` or `https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)` will change these indices, so you
must do your own thread safety between these to protect from such changes.

<br />

| Parameters ||
|---|---|
| `index` | `int`: Index of which registration cookie to return, from 0 to `https://developer.android.com/reference/android/os/RemoteCallbackList#getRegisteredCallbackCount()` - 1. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Object` | Returns whatever cookie object is associated with this index, or null if `https://developer.android.com/reference/android/os/RemoteCallbackList#kill()` has been called. <br /> |

### getRegisteredCallbackCount

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRegisteredCallbackCount ()
```

Returns the number of registered interfaces. Note that the number of registered
interfaces may differ from the value returned by `https://developer.android.com/reference/android/os/RemoteCallbackList#beginBroadcast()` since
the former returns the number of interfaces registered at the time of the call
and the second the number of interfaces to which the broadcast will be delivered.


This function is useful to decide whether to schedule a broadcast if this
requires doing some work which otherwise would not be performed.

<br />

<br />

| Returns ||
|---|---|
| `int` | The size. <br /> |

### getRegisteredCallbackItem

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public E getRegisteredCallbackItem (int index)
```

Return a currently registered interface. Note that this is
*not* the same as `https://developer.android.com/reference/android/os/RemoteCallbackList#getBroadcastItem(int)` and should not be used
interchangeably with it. This method returns the registered interface at the given
index, not the current broadcast state. This means that it is not itself thread-safe:
any call to `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)` or `https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)` will change these indices, so you
must do your own thread safety between these to protect from such changes.

<br />

| Parameters ||
|---|---|
| `index` | `int`: Index of which interface registration to return, from 0 to `https://developer.android.com/reference/android/os/RemoteCallbackList#getRegisteredCallbackCount()` - 1. <br /> |

| Returns ||
|---|---|
| `E` | Returns whatever interface is associated with this index, or null if `https://developer.android.com/reference/android/os/RemoteCallbackList#kill()` has been called. <br /> |

### kill

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void kill ()
```

Disable this interface list. All registered interfaces are unregistered,
and the list is disabled so that future calls to `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)` will
fail. This should be used when a Service is stopping, to prevent clients
from registering interfaces after it is stopped.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)`

### onCallbackDied

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onCallbackDied (E callbackInterface, 
                Object cookie)
```

Called when the process hosting an interface in the list has gone away.
The default implementation calls `https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E)`
for backwards compatibility.

<br />

| Parameters ||
|---|---|
| `callbackInterface` | `E`: The interface whose process has died. Note that, since its process has died, you can not make any calls on to this interface. You can, however, retrieve its IBinder and compare it with another IBinder to see if it is the same object. <br /> |
| `cookie` | `Object`: The cookie object original provided to `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E,%20java.lang.Object)`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)`

### onCallbackDied

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onCallbackDied (E callbackInterface)
```

Old version of `https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E,%20java.lang.Object)` that
does not provide a cookie.

<br />

| Parameters ||
|---|---|
| `callbackInterface` | `E` <br /> |

### register

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean register (E callbackInterface, 
                Object cookie)
```

Add a new interface to the list. This interface will remain in the list
until a corresponding call to `https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)` or its hosting process
goes away. If the interface was already registered (determined by
checking to see if the `https://developer.android.com/reference/android/os/IInterface#asBinder()`
object is already in the list), then it will be replaced with the new interface.
Registrations are not counted; a single call to `https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)`
will remove an interface after any number calls to register it.

<br />

| Parameters ||
|---|---|
| `callbackInterface` | `E`: The callback interface to be added to the list. Must not be null -- passing null here will cause a NullPointerException. Most services will want to check for null before calling this with an object given from a client, so that clients can't crash the service with bad data. <br /> |
| `cookie` | `Object`: Optional additional data to be associated with this interface. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if the interface was successfully added to the list. Returns false if it was not added, either because `https://developer.android.com/reference/android/os/RemoteCallbackList#kill()` had previously been called or the interface's process has gone away. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#unregister(E)`
- `https://developer.android.com/reference/android/os/RemoteCallbackList#kill()`
- `https://developer.android.com/reference/android/os/RemoteCallbackList#onCallbackDied(E)`

### register

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean register (E callbackInterface)
```

Simple version of `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E,%20java.lang.Object)`
that does not take a cookie object.

<br />

| Parameters ||
|---|---|
| `callbackInterface` | `E` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### unregister

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean unregister (E callbackInterface)
```

Remove from the list an interface that was previously added with
`https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)`. This uses the
`https://developer.android.com/reference/android/os/IInterface#asBinder()` object to correctly
find the previous registration.
Registrations are not counted; a single unregister call will remove
an interface after any number calls to `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)` for it.

<br />

| Parameters ||
|---|---|
| `callbackInterface` | `E`: The interface to be removed from the list. Passing null here will cause a NullPointerException, so you will generally want to check for null before calling. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if the interface was found and unregistered. Returns false if the given interface was not found on the list. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/RemoteCallbackList#register(E)`