# BroadcastReceiverWithCallbacks

Artifact: [androidx.remotecallback:remotecallback](https://developer.android.com/jetpack/androidx/releases/remotecallback) [View Source](https://cs.android.com/search?q=file:androidx/remotecallback/BroadcastReceiverWithCallbacks.java+class:androidx.remotecallback.BroadcastReceiverWithCallbacks) Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/remotecallback#1.0.0-alpha03) Deprecated in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/remotecallback#1.0.0-alpha03)

*** ** * ** ***


```
public abstract class BroadcastReceiverWithCallbacks<T extends CallbackReceiver> extends BroadcastReceiver implements CallbackReceiver<T>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) ||
|   | ↳ | [androidx.remotecallback.BroadcastReceiverWithCallbacks](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks) |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Slice framework has been deprecated, it will not receive any updates moving forward. If you are looking for a framework that handles communication across apps, consider using `https://developer.android.com/reference/android/app/appsearch/AppSearchManager.html`.

Extend this broadcast receiver to be able to receive callbacks as well as normal broadcasts. Ensure that you call the super of `https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#onReceive(android.content.Context,android.content.Intent)` when the action is `https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#ACTION_BROADCAST_CALLBACK()`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/remotecallback/CallbackReceiver>` | Should be specified as the root class (e.g. class X extends BroadcastReceiverWithCallbacks\\) |

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#ACTION_BROADCAST_CALLBACK() = "androidx.remotecallback.action.BROADCAST_CALLBACK"` **This field is deprecated.** Deprecated in Java |

| ### Public constructors |
|---|
| `[BroadcastReceiverWithCallbacks](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#BroadcastReceiverWithCallbacks())()` **This method is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html T` | `[createRemoteCallback](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#createRemoteCallback(android.content.Context))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` **This method is deprecated.** Deprecated in Java |
| `void` | `[onReceive](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#onReceive(android.content.Context,android.content.Intent))(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/content/Intent.html intent)` **This method is deprecated.** Deprecated in Java |

### Inherited methods

From [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) `final void` `[abortBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast())()`

**This method is deprecated.** Deprecated in Java
`final void` `[clearAbortBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#clearAbortBroadcast())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[getAbortBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getAbortBroadcast())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[getDebugUnregister](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getDebugUnregister())()`

**This method is deprecated.** Deprecated in Java
`final int` `[getResultCode](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultCode())()`

**This method is deprecated.** Deprecated in Java
`final https://developer.android.com/reference/java/lang/String.html` `[getResultData](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultData())()`

**This method is deprecated.** Deprecated in Java
`final https://developer.android.com/reference/android/os/Bundle.html` `[getResultExtras](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultExtras(boolean))(boolean makeMap)`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/java/lang/String.html` `[getSentFromPackage](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getSentFromPackage())()`

**This method is deprecated.** Deprecated in Java
`int` `[getSentFromUid](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getSentFromUid())()`

**This method is deprecated.** Deprecated in Java
`final https://developer.android.com/reference/android/content/BroadcastReceiver.PendingResult.html` `[goAsync](https://developer.android.com/reference/android/content/BroadcastReceiver.html#goAsync())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isInitialStickyBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#isInitialStickyBroadcast())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isOrderedBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#isOrderedBroadcast())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/os/IBinder.html` `[peekService](https://developer.android.com/reference/android/content/BroadcastReceiver.html#peekService(android.content.Context, android.content.Intent))(https://developer.android.com/reference/android/content/Context.html myContext, https://developer.android.com/reference/android/content/Intent.html service)`

**This method is deprecated.** Deprecated in Java
`final void` `[setDebugUnregister](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setDebugUnregister(boolean))(boolean debug)`

**This method is deprecated.** Deprecated in Java
`final void` `[setOrderedHint](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setOrderedHint(boolean))(boolean isOrdered)`

**This method is deprecated.** Deprecated in Java
`final void` `[setResult](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResult(int, java.lang.String, android.os.Bundle))(int code, https://developer.android.com/reference/java/lang/String.html data, https://developer.android.com/reference/android/os/Bundle.html extras)`

**This method is deprecated.** Deprecated in Java
`final void` `[setResultCode](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultCode(int))(int code)`

**This method is deprecated.** Deprecated in Java
`final void` `[setResultData](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultData(java.lang.String))(https://developer.android.com/reference/java/lang/String.html data)`

**This method is deprecated.** Deprecated in Java
`final void` `[setResultExtras](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultExtras(android.os.Bundle))(https://developer.android.com/reference/android/os/Bundle.html extras)`

**This method is deprecated.** Deprecated in Java

## Constants

### ACTION_BROADCAST_CALLBACK

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/remotecallback#1.0.0-alpha03) Deprecated in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/remotecallback#1.0.0-alpha03)

```
public static final String ACTION_BROADCAST_CALLBACK = "androidx.remotecallback.action.BROADCAST_CALLBACK"
```

> [!CAUTION]
> **This field is deprecated.**   
> Deprecated in Java

The action used for incoming RemoteCallbacks.

## Public constructors

### BroadcastReceiverWithCallbacks

Added in 1.0.0-alpha03 Deprecated in 1.0.0-alpha03

```
public [BroadcastReceiverWithCallbacks](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#BroadcastReceiverWithCallbacks())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

## Public methods

### createRemoteCallback

```
public @NonNull T [createRemoteCallback](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#createRemoteCallback(android.content.Context))(@NonNull Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Creates a `https://developer.android.com/reference/androidx/remotecallback/RemoteCallback` that will call the method with method specified with the arguments specified when triggered. Only methods tagged with `https://developer.android.com/reference/androidx/remotecallback/RemoteCallable` can be used here. This method returns a stub implementation of the class calling it to record the arguments/method being used. This should only be used in a chain of 2 calls, starting with createRemoteCallback(), then followed up with a call to any method tagged with `https://developer.android.com/reference/androidx/remotecallback/RemoteCallable`.

```
    createRemoteCallback().callMyMethod("My arguments", 43, 2.4)
             .toPendingIntent(context);
```

```
    \@RemoteCallable
    public RemoteCallback callMyMethod(String argStr, int argInt, double argDouble) {
        ...
        return RemoteCallback.LOCAL;
    }
```

### onReceive

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/remotecallback#1.0.0-alpha03) Deprecated in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/remotecallback#1.0.0-alpha03)

```
public void [onReceive](https://developer.android.com/reference/androidx/remotecallback/BroadcastReceiverWithCallbacks#onReceive(android.content.Context,android.content.Intent))(Context context, Intent intent)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java