# 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)

*** ** * ** ***


```
abstract class BroadcastReceiverWithCallbacks<T : CallbackReceiver?> : BroadcastReceiver, CallbackReceiver<T!>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) ||
|   | ↳ | [androidx.remotecallback.BroadcastReceiverWithCallbacks](https://developer.android.com/reference/kotlin/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/kotlin/androidx/remotecallback/BroadcastReceiverWithCallbacks#onReceive(android.content.Context,android.content.Intent)` when the action is `https://developer.android.com/reference/kotlin/androidx/remotecallback/BroadcastReceiverWithCallbacks#ACTION_BROADCAST_CALLBACK()`.

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

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/remotecallback/BroadcastReceiverWithCallbacks#ACTION_BROADCAST_CALLBACK() = "androidx.remotecallback.action.BROADCAST_CALLBACK"` **This property is deprecated.** Deprecated in Java |

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

| ### Public functions |
|---|---|
| `T` | `[createRemoteCallback](https://developer.android.com/reference/kotlin/androidx/remotecallback/BroadcastReceiverWithCallbacks#createRemoteCallback(android.content.Context))(context: https://developer.android.com/reference/android/content/Context.html)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onReceive](https://developer.android.com/reference/kotlin/androidx/remotecallback/BroadcastReceiverWithCallbacks#onReceive(android.content.Context,android.content.Intent))(context: https://developer.android.com/reference/android/content/Context.html!, intent: https://developer.android.com/reference/android/content/Intent.html!)` **This function is deprecated.** Deprecated in Java |

### Inherited functions

From [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[abortBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[clearAbortBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#clearAbortBroadcast())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[getAbortBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getAbortBroadcast())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[getDebugUnregister](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getDebugUnregister())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `[getResultCode](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultCode())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `[getResultData](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultData())()`

**This function is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/os/Bundle.html!` `[getResultExtras](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultExtras(boolean))(makeMap: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `[getSentFromPackage](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getSentFromPackage())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `[getSentFromUid](https://developer.android.com/reference/android/content/BroadcastReceiver.html#getSentFromUid())()`

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

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[isInitialStickyBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#isInitialStickyBroadcast())()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[isOrderedBroadcast](https://developer.android.com/reference/android/content/BroadcastReceiver.html#isOrderedBroadcast())()`

**This function 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))(myContext: https://developer.android.com/reference/android/content/Context.html!, service: https://developer.android.com/reference/android/content/Intent.html!)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setDebugUnregister](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setDebugUnregister(boolean))(debug: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setOrderedHint](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setOrderedHint(boolean))(isOrdered: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setResult](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResult(int, java.lang.String, android.os.Bundle))(code: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, extras: https://developer.android.com/reference/android/os/Bundle.html!)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setResultCode](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultCode(int))(code: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setResultData](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultData(java.lang.String))(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[setResultExtras](https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultExtras(android.os.Bundle))(extras: https://developer.android.com/reference/android/os/Bundle.html!)`

**This function 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)

```
const val ACTION_BROADCAST_CALLBACK = "androidx.remotecallback.action.BROADCAST_CALLBACK": String!
```

> [!CAUTION]
> **This property 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

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

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

## Public functions

### createRemoteCallback

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

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

Creates a `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/remotecallback/RemoteCallable`.

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

```kotlin
    \@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)

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

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