AppFunctionMetadata
public
final
class
AppFunctionMetadata
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | 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:
<appfunctions>
<appfunction>
<id>createNote</id>
<enabledByDefault>true</enabledByDefault>
<scope>global</scope>
...
</appfunction>
</appfunctions>
See AppFunctionManager.getAppFunctionStates for details on retrieving the runtime
state of the app functions.
Summary
Constants | |
|---|---|
String |
PROPERTY_ENABLED_BY_DEFAULT
Property name for the XML tag that defines the default value of |
String |
PROPERTY_FUNCTION_ID
Property name for the XML tag that defines the value of |
String |
PROPERTY_SCHEMA_CATEGORY
Property name for the XML tag that defines the value of |
String |
PROPERTY_SCHEMA_NAME
Property name for the XML tag that defines the value of |
String |
PROPERTY_SCHEMA_VERSION
Property name for the XML tag that defines the value of |
String |
PROPERTY_SCOPE
Property name for the XML tag that defines the value of |
String |
PROPERTY_VALUE_SCOPE_ACTIVITY
Property value for |
String |
PROPERTY_VALUE_SCOPE_GLOBAL
Property value for |
int |
SCOPE_ACTIVITY
A value returned from |
int |
SCOPE_GLOBAL
A value returned from |
Inherited constants |
|---|
Fields | |
|---|---|
public
static
final
Creator<AppFunctionMetadata> |
CREATOR
|
Public methods | |
|---|---|
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
boolean
|
equals(Object o)
Indicates whether some other object is "equal to" this one. |
GenericDocument
|
getMetadataDocument()
Returns the app function's metadata as a |
AppFunctionName
|
getName()
Returns the qualified name of the app function. |
AppFunctionPackageMetadata
|
getPackageMetadata()
Returns the |
AppFunctionSchemaMetadata
|
getSchemaMetadata()
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. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
|---|---|
Constants
PROPERTY_ENABLED_BY_DEFAULT
public static final String PROPERTY_ENABLED_BY_DEFAULT
Property name for the XML tag that defines the default value of AppFunctionState.isEnabled, before calling AppFunctionManager.setAppFunctionEnabled.
Constant Value: "enabledByDefault"
PROPERTY_FUNCTION_ID
public static final String PROPERTY_FUNCTION_ID
Property name for the XML tag that defines the value of AppFunctionName.getFunctionIdentifier returned by getName().
Constant Value: "id"
PROPERTY_SCHEMA_CATEGORY
public static final String PROPERTY_SCHEMA_CATEGORY
Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getCategory returned by getSchemaMetadata().
Constant Value: "schemaCategory"
PROPERTY_SCHEMA_NAME
public static final String PROPERTY_SCHEMA_NAME
Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getName returned by getSchemaMetadata().
Constant Value: "schemaName"
PROPERTY_SCHEMA_VERSION
public static final String PROPERTY_SCHEMA_VERSION
Property name for the XML tag that defines the value of AppFunctionSchemaMetadata.getVersion returned by getSchemaMetadata().
Constant Value: "schemaVersion"
PROPERTY_SCOPE
public static final String PROPERTY_SCOPE
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.
See also:
Constant Value: "scope"
PROPERTY_VALUE_SCOPE_ACTIVITY
public static final String PROPERTY_VALUE_SCOPE_ACTIVITY
Property value for PROPERTY_SCOPE in the XML representing SCOPE_ACTIVITY.
Constant Value: "activity"
PROPERTY_VALUE_SCOPE_GLOBAL
public static final String PROPERTY_VALUE_SCOPE_GLOBAL
Property value for PROPERTY_SCOPE in the XML representing SCOPE_GLOBAL.
Constant Value: "global"
SCOPE_ACTIVITY
public static final int SCOPE_ACTIVITY
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 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 ERROR(ExecuteAppFunctionRequest.setActivityId/android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId 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 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.
Constant Value: 1 (0x00000001)
SCOPE_GLOBAL
public static final int SCOPE_GLOBAL
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 ERROR(ExecuteAppFunctionRequest.setActivityId/android.app.appfunctions.ExecuteAppFunctionRequest#setActivityId 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 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.
Constant Value: 0 (0x00000000)
Fields
Public methods
describeContents
public int describeContents ()
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.
| Returns | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or
|
equals
public boolean equals (Object o)
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 | |
|---|---|
o |
Object: the reference object with which to compare. |
| Returns | |
|---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getMetadataDocument
public GenericDocument getMetadataDocument ()
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.
| Returns | |
|---|---|
GenericDocument |
This value cannot be null. |
getName
public AppFunctionName getName ()
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.
| Returns | |
|---|---|
AppFunctionName |
This value cannot be null. |
getPackageMetadata
public AppFunctionPackageMetadata getPackageMetadata ()
Returns the AppFunctionPackageMetadata of the enclosing package.
| Returns | |
|---|---|
AppFunctionPackageMetadata |
This value cannot be null. |
getSchemaMetadata
public AppFunctionSchemaMetadata getSchemaMetadata ()
Returns the identifying metadata for a pre-defined schema which this app function implements.
| Returns | |
|---|---|
AppFunctionSchemaMetadata |
This value may be null. |
getScope
public int getScope ()
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.
| Returns | |
|---|---|
int |
Value is one of the following: |
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
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.
| Returns | |
|---|---|
int |
a hash code value for this object. |
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
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.PARCELABLE_WRITE_RETURN_VALUE.
Value is either 0 or a combination of the following:
|