# 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
public fun interface AppFunction
```

<br />

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/appfunctions/AppFunction#onExecuteAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest,android.os.CancellationSignal,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest request, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse> callback )` Called when the app function is invoked using `https://developer.android.com/reference/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)`. |

## Public methods

### onExecuteAppFunction

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

```
abstract void onExecuteAppFunction(
    @NonNull ExecuteAppFunctionRequest request,
    @NonNull CancellationSignal cancellationSignal,
    @NonNull Consumer<@NonNull ExecuteAppFunctionResponse> callback
)
```

Called when the app function is invoked using `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest request` | The `https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest` containing the parameters for this execution. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal` | A signal to cancel the execution. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse> callback` | 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/androidx/appfunctions/ExecuteAppFunctionResponse.Success` or `https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse.Error` in case of an error. |