# AppFunction

Artifact: [androidx.appfunctions:appfunctions](https://developer.android.com/jetpack/androidx/releases/appfunctions) [View Source](https://cs.android.com/search?q=file:androidx/appfunctions/AppFunction.kt+class:androidx.appfunctions.AppFunction) Added in [1.0.0-rc01](https://developer.android.com/jetpack/androidx/releases/appfunctions#1.0.0-rc01)

*** ** * ** ***


```
@ExperimentalAppFunctionsApi
fun interface AppFunction
```

<br />

*** ** * ** ***

An interface for implementing the logic of an app function registered at runtime using `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#registerAppFunction(kotlin.String,java.util.concurrent.Executor,androidx.appfunctions.AppFunction)`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunction#onExecuteAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest,android.os.CancellationSignal,java.util.function.Consumer)( request: https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionRequest, cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html, callback: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionResponse> )` Called when the app function is invoked using `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)`. |

## Public functions

### onExecuteAppFunction

Added in [1.0.0-rc01](https://developer.android.com/jetpack/androidx/releases/appfunctions#1.0.0-rc01)

```
fun onExecuteAppFunction(
    request: ExecuteAppFunctionRequest,
    cancellationSignal: CancellationSignal,
    callback: Consumer<ExecuteAppFunctionResponse>
): Unit
```

Called when the app function is invoked using `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)`.

The implementation should try to respect the provided `https://developer.android.com/reference/android/os/CancellationSignal.html`, if possible.

| Parameters |
|---|---|
| `request: https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionRequest` | The `https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionRequest` containing the parameters for this execution. |
| `cancellationSignal: https://developer.android.com/reference/android/os/CancellationSignal.html` | A signal to cancel the execution. |
| `callback: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionResponse>` | The `https://developer.android.com/reference/java/util/function/Consumer.html` that the implementation must use to return the result of the execution. It must be called exactly once with either a successful `https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionResponse.Success` or `https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionResponse.Error` in case of an error. |