AppFunctionMetadata


public final 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

static final int

A constant indicating an app function is activity-scoped.

static final int

A constant indicating an app function is globally-scoped.

Public constructors

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

Public methods

boolean
equals(Object other)
final AppFunctionDeprecationMetadata

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

final @NonNull String

A description of the app function and its intended use.

final @NonNull String

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

final @NonNull AppFunctionName

The qualified name of the app function.

final @NonNull AppFunctionPackageMetadata

The AppFunctionPackageMetadata of the enclosing package.

final @NonNull String

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

final @NonNull List<@NonNull AppFunctionParameterMetadata>

The parameters of the app function.

final @NonNull AppFunctionResponseMetadata

The response of the app function.

final AppFunctionSchemaMetadata

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

final int

The scope of the app function.

int
@NonNull String

Constants

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

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

Public methods

equals

public boolean equals(Object other)

getDeprecation

Added in 1.0.0-alpha12
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-alpha12
public final @NonNull String getDescription()

A description of the app function and its intended use.

getId

Added in 1.0.0-alpha12
public final @NonNull String getId()

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

getName

Added in 1.0.0-alpha12
public final @NonNull AppFunctionName getName()

The qualified name of the app function.

getPackageMetadata

Added in 1.0.0-alpha12
public final @NonNull AppFunctionPackageMetadata getPackageMetadata()

The AppFunctionPackageMetadata of the enclosing package.

getPackageName

Added in 1.0.0-alpha12
public final @NonNull String getPackageName()

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

getParameters

Added in 1.0.0-alpha12
public final @NonNull List<@NonNull AppFunctionParameterMetadatagetParameters()

The parameters of the app function.

getResponse

Added in 1.0.0-alpha12
public final @NonNull AppFunctionResponseMetadata getResponse()

The response of the app function.

getSchema

Added in 1.0.0-alpha12
public final AppFunctionSchemaMetadata getSchema()

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

getScope

Added in 1.0.0-alpha12
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 AppFunctionName.

See SCOPE_GLOBAL and SCOPE_ACTIVITY for more details on each scope.

hashCode

public int hashCode()

toString

public @NonNull String toString()