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

*** ** * ** ***


```
public final class AppFunctionMetadata
```

<br />

*** ** * ** ***

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

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

## Summary

| ### Constants |
|---|---|
| `static final int` | `@https://developer.android.com/reference/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/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. |
| `static final int` | `@https://developer.android.com/reference/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SELF() = 100` Strictly restricted to callers with the same UID as the hosting application. |
| `static final int` | `@https://developer.android.com/reference/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM() = 200` Accessible by holders of the `android.permission.EXECUTE_APP_FUNCTIONS_SYSTEM` permission. |
| `static final int` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()` A constant indicating an app function is activity-scoped. |
| `static final int` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_GLOBAL()` A constant indicating an app function is globally-scoped. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/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)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/AppFunctionName name, https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionSchemaMetadata schema, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionParameterMetadata> parameters, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionResponseMetadata response, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionPackageMetadata packageMetadata, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description, https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDeprecationMetadata deprecation, int scope )` |
| `@https://developer.android.com/reference/androidx/appfunctions/ExperimentalAppFunctionsApi https://developer.android.com/reference/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)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/AppFunctionName name, https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionSchemaMetadata schema, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionParameterMetadata> parameters, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionResponseMetadata response, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionPackageMetadata packageMetadata, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html description, https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDeprecationMetadata deprecation, int scope, int accessLevel, boolean isCompatEnforcementEnabled )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final int` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getAccessLevel()()` The minimum access level required to invoke the app function. |
| `final https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionDeprecationMetadata` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getDeprecation()()` Deprecation details about the function, if the app function is deprecated. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getDescription()()` A description of the app function and its intended use. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getId()()` The ID used in an `https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest` to refer to this app function. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/AppFunctionName` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getName()()` The qualified name of the app function. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionPackageMetadata` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getPackageMetadata()()` The `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionPackageMetadata` of the enclosing package. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getPackageName()()` The package name of the Android app called to execute the app function. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionParameterMetadata>` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getParameters()()` The parameters of the app function. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionResponseMetadata` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getResponse()()` The response of the app function. |
| `final https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionSchemaMetadata` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getSchema()()` The identifying metadata for a pre-defined schema which this app function implements. |
| `final int` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#getScope()()` The scope of the app function. |
| `int` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#isCompatEnforcementEnabled()()` Whether access level enforcement is enabled on older platform versions (pre-17.2). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#toString()()` |

## Constants

### ACCESS_LEVEL_ANDROID_TRUSTED

```
@ExperimentalAppFunctionsApi
public static final int ACCESS_LEVEL_ANDROID_TRUSTED = 300
```

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/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM()` and `https://developer.android.com/reference/androidx/appfunctions/metadata/AppFunctionMetadata#ACCESS_LEVEL_SELF()`.

### ACCESS_LEVEL_SELF

```
@ExperimentalAppFunctionsApi
public static final int ACCESS_LEVEL_SELF = 100
```

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

### ACCESS_LEVEL_SYSTEM

```
@ExperimentalAppFunctionsApi
public static final int ACCESS_LEVEL_SYSTEM = 200
```

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

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

### SCOPE_ACTIVITY

```
public static final int SCOPE_ACTIVITY
```

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/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/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)` must use android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId, otherwise `https://developer.android.com/reference/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/androidx/appfunctions/AppFunctionManager#getAppFunctionStates(kotlin.collections.List)` and `https://developer.android.com/reference/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/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/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()`. Only use `https://developer.android.com/reference/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

```
public static final int SCOPE_GLOBAL
```

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/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/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/androidx/appfunctions/AppFunctionFunctionNotFoundException` will be returned.

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

**IMPORTANT:** Functions provided with `https://developer.android.com/reference/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/androidx/appfunctions/metadata/AppFunctionMetadata#SCOPE_ACTIVITY()`. Only use `https://developer.android.com/reference/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)

```
public AppFunctionMetadata(
    @NonNull AppFunctionName name,
    AppFunctionSchemaMetadata schema,
    @NonNull List<@NonNull AppFunctionParameterMetadata> parameters,
    @NonNull AppFunctionResponseMetadata response,
    @NonNull AppFunctionPackageMetadata packageMetadata,
    @NonNull String description,
    AppFunctionDeprecationMetadata deprecation,
    int scope
)
```

### AppFunctionMetadata

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

```
@ExperimentalAppFunctionsApi
public AppFunctionMetadata(
    @NonNull AppFunctionName name,
    AppFunctionSchemaMetadata schema,
    @NonNull List<@NonNull AppFunctionParameterMetadata> parameters,
    @NonNull AppFunctionResponseMetadata response,
    @NonNull AppFunctionPackageMetadata packageMetadata,
    @NonNull String description,
    AppFunctionDeprecationMetadata deprecation,
    int scope,
    int accessLevel,
    boolean isCompatEnforcementEnabled
)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getAccessLevel

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

```
public final int getAccessLevel()
```

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

Value is one of the following:

- `100`
- `200`
- `300`

<br />

### getDeprecation

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

```
public final AppFunctionDeprecationMetadata getDeprecation()
```

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

### getDescription

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

```
public final @NonNull String getDescription()
```

A description of the app function and its intended use.

### getId

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

```
public final @NonNull String getId()
```

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

### getName

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

```
public final @NonNull AppFunctionName getName()
```

The qualified name of the app function.

### getPackageMetadata

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

```
public final @NonNull AppFunctionPackageMetadata getPackageMetadata()
```

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

### getPackageName

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

```
public final @NonNull String getPackageName()
```

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

### getParameters

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

```
public final @NonNull List<@NonNull AppFunctionParameterMetadata> getParameters()
```

The parameters of the app function.

### getResponse

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

```
public final @NonNull AppFunctionResponseMetadata getResponse()
```

The response of the app function.

### getSchema

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

```
public final AppFunctionSchemaMetadata getSchema()
```

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

### getScope

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

```
public final int getScope()
```

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/androidx/appfunctions/AppFunctionName`.

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

Value is one of the following:

- `0`
- `1`

<br />

### hashCode

```
public int hashCode()
```

### isCompatEnforcementEnabled

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

```
public final boolean isCompatEnforcementEnabled()
```

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

### toString

```
public @NonNull String toString()
```