AppFunctionMetadata


class AppFunctionMetadata


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

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

Summary

Constants

const Int

A constant indicating an app function is activity-scoped.

const Int

A constant indicating an app function is globally-scoped.

Public constructors

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

Public functions

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

AppFunctionDeprecationMetadata?

Deprecation details about the function, if the app function is deprecated.

String

A description of the app function and its intended use.

String

The ID used in an androidx.appfunctions.ExecuteAppFunctionRequest to refer to this app function.

AppFunctionName

The qualified name of the app function.

AppFunctionPackageMetadata

The AppFunctionPackageMetadata of the enclosing package.

String

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

List<AppFunctionParameterMetadata>

The parameters of the app function.

AppFunctionResponseMetadata

The response of the app function.

AppFunctionSchemaMetadata?

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

Int

The scope of the app function.

Constants

SCOPE_ACTIVITY

const val SCOPE_ACTIVITYInt

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 android.app.Activity instance, which is identified by an android.app.appfunctions.AppFunctionActivityId.

Functions with this scope must be registered by an androidx.appfunctions.AppFunctionManager that is created from an android.app.Activity context.

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

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

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

IMPORTANT: Functions provided with androidx.appfunctions.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.

SCOPE_GLOBAL

const val SCOPE_GLOBALInt

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 androidx.appfunctions.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 androidx.appfunctions.AppFunctionManager.executeAppFunction must not use android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId (or set it to null), otherwise androidx.appfunctions.AppFunctionFunctionNotFoundException will be returned.

This is always the scope for androidx.appfunctions.AppFunctionService-based functions.

IMPORTANT: Functions provided with androidx.appfunctions.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.

Public constructors

AppFunctionMetadata

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

Public functions

equals

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

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

deprecation

Added in 1.0.0-alpha12
val deprecationAppFunctionDeprecationMetadata?

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-alpha12
val descriptionString

A description of the app function and its intended use.

id

Added in 1.0.0-alpha12
val idString

The ID used in an androidx.appfunctions.ExecuteAppFunctionRequest to refer to this app function.

name

Added in 1.0.0-alpha12
val nameAppFunctionName

The qualified name of the app function.

packageMetadata

Added in 1.0.0-alpha12
val packageMetadataAppFunctionPackageMetadata

The AppFunctionPackageMetadata of the enclosing package.

packageName

Added in 1.0.0-alpha12
val packageNameString

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

parameters

Added in 1.0.0-alpha12
val parametersList<AppFunctionParameterMetadata>

The parameters of the app function.

response

Added in 1.0.0-alpha12
val responseAppFunctionResponseMetadata

The response of the app function.

schema

Added in 1.0.0-alpha12
val schemaAppFunctionSchemaMetadata?

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

scope

Added in 1.0.0-alpha12
val scopeInt

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 SCOPE_GLOBAL and SCOPE_ACTIVITY for more details on each scope.