# AppFunctionMetadata

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

*** ** * ** ***


```
class AppFunctionMetadata
```

<br />

*** ** * ** ***

Contains an app function's metadata, essential for its invocation and discovery, retrieved using `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#searchAppFunctions(androidx.appfunctions.AppFunctionSearchSpec)`.

See `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#getAppFunctionStates(kotlin.collections.List)` for details on retrieving the runtime state of the app functions.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_ANDROID_TRUSTED() = 300` Accessible by any caller certified by Android that holds the `android.permission.EXECUTE_APP_FUNCTIONS` permission. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SELF() = 100` Strictly restricted to callers with the same UID as the hosting application. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM() = 200` Accessible by holders of the `android.permission.EXECUTE_APP_FUNCTIONS_SYSTEM` permission. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()` A constant indicating an app function is activity-scoped. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_GLOBAL()` A constant indicating an app function is globally-scoped. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#AppFunctionMetadata(androidx.appfunctions.AppFunctionName,androidx.appfunctions.metadata.AppFunctionSchemaMetadata,kotlin.collections.List,androidx.appfunctions.metadata.AppFunctionResponseMetadata,androidx.appfunctions.metadata.AppFunctionPackageMetadata,kotlin.String,androidx.appfunctions.metadata.AppFunctionDeprecationMetadata,kotlin.Int)( name: https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionName, schema: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionSchemaMetadata?, parameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionParameterMetadata>, response: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionResponseMetadata, packageMetadata: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionPackageMetadata, description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, deprecation: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionDeprecationMetadata?, scope: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |
| `@https://developer.android.com/reference/kotlin/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#AppFunctionMetadata(androidx.appfunctions.AppFunctionName,androidx.appfunctions.metadata.AppFunctionSchemaMetadata,kotlin.collections.List,androidx.appfunctions.metadata.AppFunctionResponseMetadata,androidx.appfunctions.metadata.AppFunctionPackageMetadata,kotlin.String,androidx.appfunctions.metadata.AppFunctionDeprecationMetadata,kotlin.Int,kotlin.Int,kotlin.Boolean)( name: https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionName, schema: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionSchemaMetadata?, parameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionParameterMetadata>, response: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionResponseMetadata, packageMetadata: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionPackageMetadata, description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, deprecation: https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionDeprecationMetadata?, scope: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, accessLevel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, isCompatEnforcementEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#accessLevel()` The minimum access level required to invoke the app function. |
| `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionDeprecationMetadata?` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#deprecation()` Deprecation details about the function, if the app function is deprecated. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#description()` A description of the app function and its intended use. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#id()` The ID used in an `https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionRequest` to refer to this app function. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#isCompatEnforcementEnabled()` Whether access level enforcement is enabled on older platform versions (pre-17.2). |
| `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionName` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#name()` The qualified name of the app function. |
| `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionPackageMetadata` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#packageMetadata()` The `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionPackageMetadata` of the enclosing package. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#packageName()` The package name of the Android app called to execute the app function. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionParameterMetadata>` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#parameters()` The parameters of the app function. |
| `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionResponseMetadata` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#response()` The response of the app function. |
| `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionSchemaMetadata?` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#schema()` The identifying metadata for a pre-defined schema which this app function implements. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#scope()` The scope of the app function. |

## Constants

### ACCESS_LEVEL_ANDROID_TRUSTED

```
@ExperimentalAppFunctionsApi
const val ACCESS_LEVEL_ANDROID_TRUSTED = 300: Int
```

Accessible by any caller certified by Android that holds the `android.permission.EXECUTE_APP_FUNCTIONS` permission.

This is the broadest access level. It includes access for all narrower levels: `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM()` and `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SELF()`.

### ACCESS_LEVEL_SELF

```
@ExperimentalAppFunctionsApi
const val ACCESS_LEVEL_SELF = 100: Int
```

Strictly restricted to callers with the same UID as the hosting application.

### ACCESS_LEVEL_SYSTEM

```
@ExperimentalAppFunctionsApi
const val ACCESS_LEVEL_SYSTEM = 200: Int
```

Accessible by holders of the `android.permission.EXECUTE_APP_FUNCTIONS_SYSTEM` permission.

Includes access for: `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SELF()`.

### SCOPE_ACTIVITY

```
const val SCOPE_ACTIVITY: Int
```

A constant indicating an app function is activity-scoped.

Multiple app function implementations with the same name can exist simultaneously, each registered from a different `https://developer.android.com/reference/android/app/Activity.html` instance, which is identified by an `https://developer.android.com/reference/android/app/appfunctions/AppFunctionActivityId.html`.

Functions with this scope must be registered by an `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager` that is created from an `https://developer.android.com/reference/android/app/Activity.html` context.

To execute an activity-scoped function, the caller of `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)` must use android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId, otherwise `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionFunctionNotFoundException` will be returned.

To discover the specific activities where an activity-scoped function is currently registered, see `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#getAppFunctionStates(kotlin.collections.List)` and `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#getAppFunctionActivityStates(kotlin.collections.Set)`.

The function remains registered until it is explicitly unregistered or the activity is destroyed.

**IMPORTANT:** Functions provided with `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#registerAppFunction(kotlin.String,java.util.concurrent.Executor,androidx.appfunctions.AppFunction)` called from an `https://developer.android.com/reference/android/app/Activity.html` context should prefer `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()`. Only use `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_GLOBAL()` for such functions if you are absolutely sure there can be only one instance of that activity.

### SCOPE_GLOBAL

```
const val SCOPE_GLOBAL: Int
```

A constant indicating an app function is globally-scoped.

There can be at most one app function implementation with the same name available with this scope. This is useful for functions that are tied to a singleton component, such as a foreground service.

When using `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#registerAppFunction(kotlin.String,java.util.concurrent.Executor,androidx.appfunctions.AppFunction)`, the function remains registered until it is explicitly unregistered or the calling context is destroyed.

To execute a globally-scoped function, the caller of `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)` must not use android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId (or set it to null), otherwise `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionFunctionNotFoundException` will be returned.

This is always the scope for `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionService`-based functions.

**IMPORTANT:** Functions provided with `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionManager#registerAppFunction(kotlin.String,java.util.concurrent.Executor,androidx.appfunctions.AppFunction)` called from an `https://developer.android.com/reference/android/app/Activity.html` context should prefer `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()`. Only use `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_GLOBAL()` for such functions if you are absolutely sure there can be only one instance of that activity.

## Public constructors

### AppFunctionMetadata

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

```
AppFunctionMetadata(
    name: AppFunctionName,
    schema: AppFunctionSchemaMetadata?,
    parameters: List<AppFunctionParameterMetadata>,
    response: AppFunctionResponseMetadata,
    packageMetadata: AppFunctionPackageMetadata,
    description: String = "",
    deprecation: AppFunctionDeprecationMetadata? = null,
    scope: Int = SCOPE_GLOBAL
)
```

### AppFunctionMetadata

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

```
@ExperimentalAppFunctionsApi
AppFunctionMetadata(
    name: AppFunctionName,
    schema: AppFunctionSchemaMetadata?,
    parameters: List<AppFunctionParameterMetadata>,
    response: AppFunctionResponseMetadata,
    packageMetadata: AppFunctionPackageMetadata,
    description: String = "",
    deprecation: AppFunctionDeprecationMetadata? = null,
    scope: Int = SCOPE_GLOBAL,
    accessLevel: Int = ACCESS_LEVEL_ANDROID_TRUSTED,
    isCompatEnforcementEnabled: Boolean = false
)
```

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### accessLevel

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

```
@ExperimentalAppFunctionsApi
val accessLevel: Int
```

The minimum access level required to invoke the app function.

Platform enforcement of access levels is available starting in Android 17.2 (CINNAMON_BUN_2).

### deprecation

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

```
val deprecation: AppFunctionDeprecationMetadata?
```

Deprecation details about the function, if the app function is deprecated. This will be `null` if the function is not deprecated.

### description

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

```
val description: String
```

A description of the app function and its intended use.

### id

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

```
val id: String
```

The ID used in an `https://developer.android.com/reference/kotlin/androidx/appfunctions/ExecuteAppFunctionRequest` to refer to this app function.

### isCompatEnforcementEnabled

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

```
@ExperimentalAppFunctionsApi
val isCompatEnforcementEnabled: Boolean
```

Whether access level enforcement is enabled on older platform versions (pre-17.2).

### name

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

```
val name: AppFunctionName
```

The qualified name of the app function.

### packageMetadata

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

```
val packageMetadata: AppFunctionPackageMetadata
```

The `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionPackageMetadata` of the enclosing package.

### packageName

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

```
val packageName: String
```

The package name of the Android app called to execute the app function.

### parameters

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

```
val parameters: List<AppFunctionParameterMetadata>
```

The parameters of the app function.

### response

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

```
val response: AppFunctionResponseMetadata
```

The response of the app function.

### schema

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

```
val schema: AppFunctionSchemaMetadata?
```

The identifying metadata for a pre-defined schema which this app function implements.

### scope

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

```
val scope: Int
```

The scope of the app function.

The scope determines the function's lifecycle and uniqueness rules. Depending on the scope, there could be at most one or multiple functions registered in the system with the same `https://developer.android.com/reference/kotlin/androidx/appfunctions/AppFunctionName`.

See `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_GLOBAL()` and `https://developer.android.com/reference/kotlin/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()` for more details on each scope.