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><appfunctions> <appfunction> <id>createNote</id> <enabledByDefault>true</enabledByDefault> <scope>global</scope> ... </appfunction> </appfunctions> </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 |
| static String |
Property name for the XML tag that defines the value of |
| static String |
Property name for the XML tag that defines the value of |
| static String |
Property name for the XML tag that defines the value of |
| static String |
Property name for the XML tag that defines the value of |
| static String |
Property name for the XML tag that defines the value of |
| static String |
Property value for |
| static String |
Property value for |
| static Int |
A value returned from |
| static Int |
A value returned from |
| Inherited constants | |
|---|---|
| Public methods | |
|---|---|
| Int |
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| Boolean |
Indicates whether some other object is "equal to" this one. |
| GenericDocument |
Returns the app function's metadata as a |
| AppFunctionName |
getName()Returns the qualified name of the app function. |
| AppFunctionPackageMetadata |
Returns the |
| AppFunctionSchemaMetadata? |
Returns the identifying metadata for a pre-defined schema which this app function implements. |
| Int |
getScope()Returns the scope of the app function. |
| Int |
hashCode()Returns a hash code value for the object. |
| String |
toString()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
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
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
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
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
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
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
static val PROPERTY_VALUE_SCOPE_ACTIVITY: String
Property value for PROPERTY_SCOPE in the XML representing SCOPE_ACTIVITY.
Value: "activity"PROPERTY_VALUE_SCOPE_GLOBAL
static val PROPERTY_VALUE_SCOPE_GLOBAL: String
Property value for PROPERTY_SCOPE in the XML representing SCOPE_GLOBAL.
Value: "global"SCOPE_ACTIVITY
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: 1SCOPE_GLOBAL
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: 0Public methods
describeContents
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
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 returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
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
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
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
fun getPackageMetadata(): AppFunctionPackageMetadata
Returns the AppFunctionPackageMetadata of the enclosing package.
| Return | |
|---|---|
AppFunctionPackageMetadata |
This value cannot be null. |
getSchemaMetadata
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
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
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
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons 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
equalsmethod, then calling thehashCodemethod 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
equalsmethod, then calling thehashCodemethod 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
fun toString(): String
Returns a string representation of the object.
| Return | |
|---|---|
String |
a string representation of the object. |
writeToParcel
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:
|