Language

AppFunctionMetadataScope Enum

Definition

public enum AppFunctionMetadataScope
type AppFunctionMetadataScope = 
Inheritance
AppFunctionMetadataScope

Fields

Name Value Description
Global 0

A constant indicating an app function is globally-scoped.

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 ExecuteAppFunctionRequest.Builder.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 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.

Android reference for android.app.appfunctions.AppFunctionMetadata.SCOPE_GLOBAL.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Activity 1

A constant indicating an app function is activity-scoped.

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

Functions with this scope must be registered using AppFunctionManager.registerAppFunction, and must be called from an 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 ExecuteAppFunctionRequest.Builder.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 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.

Android reference for android.app.appfunctions.AppFunctionMetadata.SCOPE_ACTIVITY.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to