Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#constants) \| [Inherited Constants](https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#inhconstants) \| [Fields](https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#lfields) \| [Methods](https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#inhmethods)

# AppFunctionMetadata

*** ** * ** ***


`
public

final

class
AppFunctionMetadata
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.appfunctions.AppFunctionMetadata |

<br />

*** ** * ** ***

Contains an app function's metadata, essential for its invocation and discovery, retrieved using
`https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#searchAppFunctions(android.app.appfunctions.AppFunctionSearchSpec,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionMetadata>,java.lang.Exception>)`.

This metadata is defined in an XML asset file and does not change at runtime. The XML file is
referenced from the app's `AndroidManifest.xml`. How it's referenced depends on whether the
app function is implemented using `https://developer.android.com/reference/android/app/appfunctions/AppFunctionService` or `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#registerAppFunction(java.lang.String,%20java.util.concurrent.Executor,%20android.app.appfunctions.AppFunction)`.

The XML schema consists of a root `<appfunctions>` element that can contain one or more
`<appfunction>` elements. The XML tags used within the `<appfunction>` element
directly correspond to the property names defined by the `PROPERTY_*` constants in this
class. All properties in the XML (including unknown properties) are made available through the
`https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getMetadataDocument()` method.

**Example `assets/app_functions.xml` declaration:**

    <appfunctions>
        <appfunction>
            <id>createNote</id>
            <enabledByDefault>true</enabledByDefault>
            <scope>global</scope>
            ...
        </appfunction>
    </appfunctions>

See `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#getAppFunctionStates(java.util.List<android.app.appfunctions.AppFunctionName>,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionState>,java.lang.Exception>)` for details on retrieving the runtime
state of the app functions.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_ANDROID_TRUSTED` A constant indicating that the app function is accessible by any caller certified by Android that holds the `https://developer.android.com/reference/android/Manifest.permission#EXECUTE_APP_FUNCTIONS` permission. |
| `int` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SELF` A constant indicating that the app function is strictly restricted to the app itself. |
| `int` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM` A constant indicating that the app function is accessible by holders of the `https://developer.android.com/` permission. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_ACCESS_LEVEL` Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getAccessLevel()`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_ENABLED_BY_DEFAULT` Property name for the XML tag that defines the default value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionState#isEnabled()`, before calling `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#setAppFunctionEnabled(java.lang.String,%20int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.lang.Void,java.lang.Exception>)`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_FUNCTION_ID` Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionName#getFunctionIdentifier()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getName()`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCHEMA_CATEGORY` Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata#getCategory()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCHEMA_NAME` Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata#getName()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCHEMA_VERSION` Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata#getVersion()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCOPE` Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getScope()`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_ANDROID_TRUSTED` Property value for `https://developer.android.com/` representing that the function is accessible by any caller certified by Android that holds the `https://developer.android.com/reference/android/Manifest.permission#EXECUTE_APP_FUNCTIONS` permission. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_SELF` Property value for `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_ACCESS_LEVEL` representing that the function is strictly restricted to the app itself. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_SYSTEM` Property value for `https://developer.android.com/` representing that the function is accessible by holders of the `"android.permission.EXECUTE_APP_FUNCTIONS_SYSTEM"` permission. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_SCOPE_ACTIVITY` Property value for `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCOPE` in the XML representing `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_ACTIVITY`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_SCOPE_GLOBAL` Property value for `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCOPE` in the XML representing `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_GLOBAL`. |
| `int` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_ACTIVITY` A constant indicating an app function is activity-scoped. |
| `int` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_GLOBAL` A constant indicating an app function is globally-scoped. |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that
the Parcelable object's flattened representation includes a file descriptor.


`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written
is a return value, that is the result of a function such as
"`Parcelable someFunction()`",
"`void someFunction(out Parcelable)`", or
"`void someFunction(inout Parcelable)`".


| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata>` | `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#CREATOR` |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` boolean` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` Indicates whether some other object is "equal to" this one. |
| ` int` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getAccessLevel()() ` Returns the minimum access level required to call the function. |
| ` https://developer.android.com/reference/android/app/appsearch/GenericDocument` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getMetadataDocument()() ` Returns the app function's metadata as a `https://developer.android.com/reference/android/app/appsearch/GenericDocument`. |
| ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionName` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getName()() ` Returns the qualified name of the app function. |
| ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionPackageMetadata` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getPackageMetadata()() ` Returns the `https://developer.android.com/reference/android/app/appfunctions/AppFunctionPackageMetadata` of the enclosing package. |
| ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()() ` Returns the identifying metadata for a pre-defined schema which this app function implements. |
| ` int` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getScope()() ` Returns the scope of the app function. |
| ` int` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#hashCode()() ` Returns a hash code value for the object. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/android/os/Parcelable

` `
abstract


int` `
https://developer.android.com/reference/android/os/Parcelable#describeContents()()
`

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.


`
abstract


void` `
https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags)
`

Flatten this object in to a Parcel.


## Constants

### ACCESS_LEVEL_ANDROID_TRUSTED

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int ACCESS_LEVEL_ANDROID_TRUSTED
```

A constant indicating that the app function is accessible by any caller certified by Android
that holds the `https://developer.android.com/reference/android/Manifest.permission#EXECUTE_APP_FUNCTIONS` permission.

This is the broadest access level. It includes access for all narrower levels: `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM`, and `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SELF`.

<br />

Constant Value:

300
(0x0000012c)


### ACCESS_LEVEL_SELF

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int ACCESS_LEVEL_SELF
```

A constant indicating that the app function is strictly restricted to the app itself.

<br />

Constant Value:

100
(0x00000064)


### ACCESS_LEVEL_SYSTEM

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int ACCESS_LEVEL_SYSTEM
```

A constant indicating that the app function is accessible by holders of the `https://developer.android.com/` permission.

Includes access for: `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SELF`.

<br />

Constant Value:

200
(0x000000c8)


### PROPERTY_ACCESS_LEVEL

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final String PROPERTY_ACCESS_LEVEL
```

Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getAccessLevel()`.

If unspecified, this defaults to `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_ANDROID_TRUSTED`.

<br />

Constant Value:

"accessLevel"


### PROPERTY_ENABLED_BY_DEFAULT

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_ENABLED_BY_DEFAULT
```

Property name for the XML tag that defines the default value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionState#isEnabled()`, before calling `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#setAppFunctionEnabled(java.lang.String,%20int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.lang.Void,java.lang.Exception>)`.

<br />

Constant Value:

"enabledByDefault"


### PROPERTY_FUNCTION_ID

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_FUNCTION_ID
```

Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionName#getFunctionIdentifier()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getName()`.

<br />

Constant Value:

"id"


### PROPERTY_SCHEMA_CATEGORY

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_SCHEMA_CATEGORY
```

Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata#getCategory()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()`.

<br />

Constant Value:

"schemaCategory"


### PROPERTY_SCHEMA_NAME

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_SCHEMA_NAME
```

Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata#getName()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()`.

<br />

Constant Value:

"schemaName"


### PROPERTY_SCHEMA_VERSION

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_SCHEMA_VERSION
```

Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata#getVersion()` returned by `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getSchemaMetadata()`.

<br />

Constant Value:

"schemaVersion"


### PROPERTY_SCOPE

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_SCOPE
```

Property name for the XML tag that defines the value of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getScope()`.

This property is should not be used for XML assets referenced by an `https://developer.android.com/reference/android/app/appfunctions/AppFunctionService` declaration in the manifest, which are always `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_GLOBAL`.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#getScope()`

Constant Value:

"scope"


### PROPERTY_VALUE_ACCESS_LEVEL_ANDROID_TRUSTED

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final String PROPERTY_VALUE_ACCESS_LEVEL_ANDROID_TRUSTED
```

Property value for `https://developer.android.com/` representing that the function is
accessible by any caller certified by Android that holds the `https://developer.android.com/reference/android/Manifest.permission#EXECUTE_APP_FUNCTIONS` permission.

This is the broadest access level. It includes access for all narrower levels: `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_SYSTEM`, and `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_SELF`.

<br />

Constant Value:

"androidTrusted"


### PROPERTY_VALUE_ACCESS_LEVEL_SELF

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final String PROPERTY_VALUE_ACCESS_LEVEL_SELF
```

Property value for `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_ACCESS_LEVEL` representing that the function is
strictly restricted to the app itself.

<br />

Constant Value:

"self"


### PROPERTY_VALUE_ACCESS_LEVEL_SYSTEM

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final String PROPERTY_VALUE_ACCESS_LEVEL_SYSTEM
```

Property value for `https://developer.android.com/` representing that the function is
accessible by holders of the `"android.permission.EXECUTE_APP_FUNCTIONS_SYSTEM"`
permission.

Includes access for: `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_VALUE_ACCESS_LEVEL_SELF`.

<br />

Constant Value:

"system"


### PROPERTY_VALUE_SCOPE_ACTIVITY

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_VALUE_SCOPE_ACTIVITY
```

Property value for `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCOPE` in the XML representing `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_ACTIVITY`.

<br />

Constant Value:

"activity"


### PROPERTY_VALUE_SCOPE_GLOBAL

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String PROPERTY_VALUE_SCOPE_GLOBAL
```

Property value for `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_SCOPE` in the XML representing `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_GLOBAL`.

<br />

Constant Value:

"global"


### SCOPE_ACTIVITY

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SCOPE_ACTIVITY
```

A constant indicating an app function is activity-scoped.

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

Functions with this scope must be registered using `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#registerAppFunction(java.lang.String,%20java.util.concurrent.Executor,%20android.app.appfunctions.AppFunction)`, and must be called from an `https://developer.android.com/reference/android/app/Activity` context. Calling it from any other context will result in an `https://developer.android.com/reference/java/lang/IllegalStateException`.

To execute an activity-scoped function, the caller of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#executeAppFunction(android.app.AppInteractionSession,%20android.app.appfunctions.ExecuteAppFunctionRequest,%20java.util.concurrent.Executor,%20android.os.CancellationSignal,%20android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse,android.app.appfunctions.AppFunctionException>)` must use `https://developer.android.com/reference/android/app/appfunctions/ExecuteAppFunctionRequest.Builder#setActivityId(android.app.appfunctions.AppFunctionActivityId)`, otherwise `https://developer.android.com/reference/android/app/appfunctions/AppFunctionException#ERROR_FUNCTION_NOT_FOUND` will be returned.

To discover the specific activities where an activity-scoped function is currently
registered, see `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#getAppFunctionStates(java.util.List<android.app.appfunctions.AppFunctionName>,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionState>,java.lang.Exception>)` and `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#getAppFunctionActivityStates(java.util.Set<android.app.appfunctions.AppFunctionActivityId>,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionActivityState>,java.lang.Exception>)`.

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

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

<br />

Constant Value:

1
(0x00000001)


### SCOPE_GLOBAL

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 `https://developer.android.com/reference/android/app/appfunctions/AppFunctionName`
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/android/app/appfunctions/AppFunctionManager#registerAppFunction(java.lang.String,%20java.util.concurrent.Executor,%20android.app.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/android/app/appfunctions/AppFunctionManager#executeAppFunction(android.app.AppInteractionSession,%20android.app.appfunctions.ExecuteAppFunctionRequest,%20java.util.concurrent.Executor,%20android.os.CancellationSignal,%20android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse,android.app.appfunctions.AppFunctionException>)` must not use `https://developer.android.com/reference/android/app/appfunctions/ExecuteAppFunctionRequest.Builder#setActivityId(android.app.appfunctions.AppFunctionActivityId)` (or set it to null), otherwise `https://developer.android.com/reference/android/app/appfunctions/AppFunctionException#ERROR_FUNCTION_NOT_FOUND` will be returned.

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

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

<br />

Constant Value:

0
(0x00000000)


## Fields

### CREATOR

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<AppFunctionMetadata> CREATOR
```

<br />

<br />

## Public methods

### describeContents

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### equals

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object o)
```

Indicates whether some other object is "equal to" this one.


The `equals` method implements an equivalence relation
on non-null object references:

- It is *reflexive*: for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is *symmetric*: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is *transitive*: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is *consistent*: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.


An equivalence relation partitions the elements it operates on
into *equivalence classes*; all the members of an
equivalence class are equal to each other. Members of an
equivalence class are substitutable for each other, at least
for some purposes.

<br />

| Parameters ||
|---|---|
| `o` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### getAccessLevel

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int getAccessLevel ()
```

Returns the minimum access level required to call the function.

Access levels are hierarchical; granting a broader access level implicitly grants
access to all narrower levels.

If unspecified, this defaults to `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_ANDROID_TRUSTED`.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SELF` - `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_SYSTEM` - `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#ACCESS_LEVEL_ANDROID_TRUSTED` |

### getMetadataDocument

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public GenericDocument getMetadataDocument ()
```

Returns the app function's metadata as a `https://developer.android.com/reference/android/app/appsearch/GenericDocument`.

Client-defined properties can be retrieved using the `https://developer.android.com/reference/android/app/appsearch/GenericDocument` property
getters.

Properties that are not defined in this class (see `PROPERTY_*` constants) are not
guaranteed to be available or consistent across devices and versions.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appsearch/GenericDocument` | This value cannot be `null`. <br /> |

### getName

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AppFunctionName getName ()
```

Returns the qualified name of the app function.

The `https://developer.android.com/reference/android/app/appfunctions/AppFunctionName` is composed of the app's package name and the function's
identifier.

This is defined by the `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#PROPERTY_FUNCTION_ID` tag in the XML.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appfunctions/AppFunctionName` | This value cannot be `null`. <br /> |

### getPackageMetadata

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AppFunctionPackageMetadata getPackageMetadata ()
```

Returns the `https://developer.android.com/reference/android/app/appfunctions/AppFunctionPackageMetadata` of the enclosing package.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appfunctions/AppFunctionPackageMetadata` | This value cannot be `null`. <br /> |

### getSchemaMetadata

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AppFunctionSchemaMetadata getSchemaMetadata ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSchemaMetadata` | This value may be `null`. <br /> |

### getScope

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getScope ()
```

Returns 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/android/app/appfunctions/AppFunctionName`.

See values below for more details on each scope.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_GLOBAL` - `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata#SCOPE_ACTIVITY` |

### hashCode

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
`https://developer.android.com/reference/java/util/HashMap`.


The general contract of `hashCode` is:

- Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
- It is *not* required that if two objects are unequal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

<br />

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### toString

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |