Added in API level 37

AppFunctionMetadata


class AppFunctionMetadata : Parcelable
kotlin.Any
   ↳ android.app.appfunctions.AppFunctionMetadata

Contains an app function's metadata, essential for its invocation and discovery, retrieved using AppFunctionManager.searchAppFunctions.

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 AppFunctionService or AppFunctionManager.registerAppFunction.

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 getMetadataDocument method.

Example assets/app_functions.xml declaration:

<code>&lt;appfunctions&gt;
      &lt;appfunction&gt;
          &lt;id&gt;createNote&lt;/id&gt;
          &lt;enabledByDefault&gt;true&lt;/enabledByDefault&gt;
          &lt;scope&gt;global&lt;/scope&gt;
          ...
      &lt;/appfunction&gt;
  &lt;/appfunctions&gt;
  </code>

See AppFunctionManager.getAppFunctionStates for details on retrieving the runtime state of the app functions.

Summary

Constants
static String

Property name for the XML tag that defines the default value of AppFunctionState.isEnabled, before calling AppFunctionManager.setAppFunctionEnabled.

static String

Property name for the XML tag that defines the value of AppFunctionName.getFunctionIdentifier returned by getName.

static String

Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getCategory returned by getSchemaMetadata.

static String

Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getName returned by getSchemaMetadata.

static String

Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getVersion returned by getSchemaMetadata.

static String

Property name for the XML tag that defines the value of getScope.

static String

Property value for PROPERTY_SCOPE in the XML representing SCOPE_ACTIVITY.

static String

Property value for PROPERTY_SCOPE in the XML representing SCOPE_GLOBAL.

static Int

A value returned from getScope that indicates it is an activity-scoped app function.

static Int

A value returned from getScope that indicates it is a globally-scoped app function.

Inherited constants
Public methods
Int

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

Boolean
equals(other: Any?)

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

GenericDocument

Returns the app function's metadata as a GenericDocument.

AppFunctionName

Returns the qualified name of the app function.

AppFunctionPackageMetadata

Returns the AppFunctionPackageMetadata of the enclosing package.

AppFunctionSchemaMetadata?

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

Int

Returns the scope of the app function.

Int

Returns a hash code value for the object.

String

Returns a string representation of the object.

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<AppFunctionMetadata!>

Constants

PROPERTY_ENABLED_BY_DEFAULT

Added in API level 37
static val PROPERTY_ENABLED_BY_DEFAULT: String

Property name for the XML tag that defines the default value of AppFunctionState.isEnabled, before calling AppFunctionManager.setAppFunctionEnabled.

Value: "enabledByDefault"

PROPERTY_FUNCTION_ID

Added in API level 37
static val PROPERTY_FUNCTION_ID: String

Property name for the XML tag that defines the value of AppFunctionName.getFunctionIdentifier returned by getName.

Value: "id"

PROPERTY_SCHEMA_CATEGORY

Added in API level 37
static val PROPERTY_SCHEMA_CATEGORY: String

Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getCategory returned by getSchemaMetadata.

Value: "schemaCategory"

PROPERTY_SCHEMA_NAME

Added in API level 37
static val PROPERTY_SCHEMA_NAME: String

Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getName returned by getSchemaMetadata.

Value: "schemaName"

PROPERTY_SCHEMA_VERSION

Added in API level 37
static val PROPERTY_SCHEMA_VERSION: String

Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getVersion returned by getSchemaMetadata.

Value: "schemaVersion"

PROPERTY_SCOPE

Added in API level 37
static val PROPERTY_SCOPE: String

Property name for the XML tag that defines the value of getScope.

This property is should not be used for XML assets referenced by an AppFunctionService declaration in the manifest, which are always SCOPE_GLOBAL.

Value: "scope"

See Also

PROPERTY_VALUE_SCOPE_ACTIVITY

Added in API level 37
static val PROPERTY_VALUE_SCOPE_ACTIVITY: String

Property value for PROPERTY_SCOPE in the XML representing SCOPE_ACTIVITY.

Value: "activity"

PROPERTY_VALUE_SCOPE_GLOBAL

Added in API level 37
static val PROPERTY_VALUE_SCOPE_GLOBAL: String

Property value for PROPERTY_SCOPE in the XML representing SCOPE_GLOBAL.

Value: "global"

SCOPE_ACTIVITY

Added in API level 37
static val SCOPE_ACTIVITY: Int

A value returned from getScope that indicates it is an activity-scoped app function.

Multiple app function implementations with the same AppFunctionName can exist simultaneously, each registered from a different android.app.Activity instance, which is identified by an AppFunctionActivityId.

Functions with this scope must be registered using AppFunctionManager.registerAppFunction, and must be called from an android.app.Activity context. Calling it from any other context will result in an IllegalStateException.

To execute an activity-scoped function, the caller of AppFunctionManager.executeAppFunction must use android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId, otherwise AppFunctionException.ERROR_FUNCTION_NOT_FOUND will be returned.

To discover the specific activities where an activity-scoped function is currently registered, see AppFunctionManager.getAppFunctionStates and AppFunctionManager.getAppFunctionActivityStates.

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

IMPORTANT: Functions provided with AppFunctionManager.registerAppFunction called from an android.app.Activity context should prefer SCOPE_ACTIVITY. Only use SCOPE_GLOBAL for such functions if you are absolutely sure there can be only one instance of that activity.

Value: 1

SCOPE_GLOBAL

Added in API level 37
static val SCOPE_GLOBAL: Int

A value returned from getScope that indicates it is a globally-scoped app function.

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

When using AppFunctionManager.registerAppFunction, the function remains registered until it is explicitly unregistered or the calling context is destroyed.

To execute a globally-scoped function, the caller of AppFunctionManager.executeAppFunction must not use android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId (or set it to null), otherwise AppFunctionException.ERROR_FUNCTION_NOT_FOUND will be returned.

This is always the scope for AppFunctionService-based functions.

IMPORTANT: Functions provided with AppFunctionManager.registerAppFunction called from an android.app.Activity context should prefer SCOPE_ACTIVITY. Only use SCOPE_GLOBAL for such functions if you are absolutely sure there can be only one instance of that activity.

Value: 0

Public methods

describeContents

Added in API level 37
fun describeContents(): Int

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 writeToParcel(Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

equals

Added in API level 37
fun equals(other: Any?): Boolean

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.

Parameters
obj the reference object with which to compare.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getMetadataDocument

Added in API level 37
fun getMetadataDocument(): GenericDocument

Returns the app function's metadata as a GenericDocument.

Client-defined properties can be retrieved using the 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.

Return
GenericDocument This value cannot be null.

getName

Added in API level 37
fun getName(): AppFunctionName

Returns the qualified name of the app function.

The AppFunctionName is composed of the app's package name and the function's identifier.

This is defined by the PROPERTY_FUNCTION_ID tag in the XML.

Return
AppFunctionName This value cannot be null.

getPackageMetadata

Added in API level 37
fun getPackageMetadata(): AppFunctionPackageMetadata

Returns the AppFunctionPackageMetadata of the enclosing package.

Return
AppFunctionPackageMetadata This value cannot be null.

getSchemaMetadata

Added in API level 37
fun getSchemaMetadata(): AppFunctionSchemaMetadata?

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

Return
AppFunctionSchemaMetadata? This value may be null.

getScope

Added in API level 37
fun getScope(): Int

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

See values below for more details on each scope.

Return
Int Value is one of the following:

hashCode

Added in API level 37
fun hashCode(): Int

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by 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 equals 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 equals 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.
Return
Int a hash code value for this object.

toString

Added in API level 37
fun toString(): String

Returns a string representation of the object.

Return
String a string representation of the object.

writeToParcel

Added in API level 37
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following:

Properties

CREATOR

Added in API level 37
static val CREATOR: Parcelable.Creator<AppFunctionMetadata!>