AppFunctionData
@RequiresApi(value = 33)
class AppFunctionData
A data class to contain information to be communicated between AppFunctions apps and agents.
This class can be logically viewed as a mapping from String keys to properties of various supported types, or arrays of supported types.
When trying to retrieve an associated value, AppFunctionData would validate the request against the predefined metadata specification provided from Builder.
For example,
fun callCreateNoteFunction(
metadata: AppFunctionMetadata,
request: ExecuteAppFunctionRequest,
) {
val response = appFunctionManager.executeAppFunction(request)
if (metadata.response.valueType is AppFunctionObjectTypeMetadata) {
val returnData = response.returnValue.getAppFunctionData(
ExecuteAppFunctionResponse.Success.PROPERTY_RETURN_VALUE
)
val title = returnData.getString("title")
// Throws an error if "owner" doesn't exist according to the metadata
val owner = returnData.getString("owner")
// Throws an error if "content" is String.
val content = returnData.getInt("content")
}
}
| See also | |
|---|---|
AppFunctionData.Builder |
Summary
Nested types |
|---|
class AppFunctionData.BuilderBuilder for constructing |
Public companion functions |
|
|---|---|
AppFunctionData |
Serializes |
Public companion properties |
|
|---|---|
AppFunctionData |
Represents an empty |
Public functions |
|
|---|---|
Boolean |
containsKey(key: String)Checks if |
T |
<T : Any> deserialize(serializableClass: Class<T>)Deserializes the |
AppFunctionData? |
getAppFunctionData(key: String)Retrieves an |
List<AppFunctionData>? |
getAppFunctionDataList(key: String)Retrieves a |
Boolean |
getBoolean(key: String)Retrieves a |
Boolean |
getBoolean(key: String, defaultValue: Boolean)Retrieves a |
BooleanArray? |
getBooleanArray(key: String)Retrieves a |
ByteArray? |
getByteArray(key: String)Retrieves a |
Double |
|
Double |
Retrieves a |
DoubleArray? |
getDoubleArray(key: String)Retrieves a |
Float |
|
Float |
Retrieves a |
FloatArray? |
getFloatArray(key: String)Retrieves a |
Int |
|
Int |
Retrieves an |
IntArray? |
getIntArray(key: String)Retrieves an |
Long |
|
Long |
Retrieves a |
LongArray? |
getLongArray(key: String)Retrieves a |
inline T? |
<T : Parcelable> getParcelable(key: String)Retrieves a |
T? |
<T : Parcelable> getParcelable(key: String, clazz: Class<T>)Retrieves a |
inline List<T>? |
<T : Parcelable> getParcelableList(key: String)Retrieves a |
List<T>? |
<T : Parcelable> getParcelableList(key: String, clazz: Class<T>)Retrieves a |
PendingIntent? |
getPendingIntent(key: String)Retrieves a |
List<PendingIntent>? |
getPendingIntentList(key: String)Retrieves a |
String? |
|
List<String>? |
getStringList(key: String)Retrieves a |
open String |
toString() |
Public properties |
|
|---|---|
String |
Qualified name of the underlying object |
Public companion functions
serialize
fun <T : Any> serialize(serializable: T, serializableClass: Class<T>): AppFunctionData
Serializes serializable to an AppFunctionData.
| Parameters | |
|---|---|
serializable: T |
The instance of |
serializableClass: Class<T> |
The class of |
| Returns | |
|---|---|
AppFunctionData |
|
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If unable to serialize |
| See also | |
|---|---|
AppFunctionSerializable |
Public companion properties
Public functions
containsKey
fun containsKey(key: String): Boolean
Checks if AppFunctionData has an associated value with the specified key.
| Parameters | |
|---|---|
key: String |
The key to checks for. |
| Returns | |
|---|---|
Boolean |
True if there is an associated value. Otherwise, false. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If there is no metadata related to |
deserialize
fun <T : Any> deserialize(serializableClass: Class<T>): T
Deserializes the AppFunctionData to an AppFunctionSerializable instance.
| Parameters | |
|---|---|
serializableClass: Class<T> |
The AppFunctionSerializable class. |
| Returns | |
|---|---|
T |
The instance of |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If unable to deserialize the |
| See also | |
|---|---|
AppFunctionSerializable |
getAppFunctionData
fun getAppFunctionData(key: String): AppFunctionData?
Retrieves an AppFunctionData value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
AppFunctionData? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getAppFunctionDataList
fun getAppFunctionDataList(key: String): List<AppFunctionData>?
Retrieves a List of AppFunctionData value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
List<AppFunctionData>? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getBoolean
fun getBoolean(key: String): Boolean
Retrieves a Boolean value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
Boolean |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getBoolean
fun getBoolean(key: String, defaultValue: Boolean): Boolean
Retrieves a Boolean value associated with the specified key, or returns defaultValue if the associated value is not found.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
defaultValue: Boolean |
The default value if the associated value is not found. |
| Returns | |
|---|---|
Boolean |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getBooleanArray
fun getBooleanArray(key: String): BooleanArray?
Retrieves a BooleanArray value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
BooleanArray? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getByteArray
fun getByteArray(key: String): ByteArray?
Retrieves a ByteArray value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getDouble
fun getDouble(key: String): Double
Retrieves a Double value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
Double |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getDouble
fun getDouble(key: String, defaultValue: Double): Double
Retrieves a Double value associated with the specified key, or returns defaultValue if the associated value is not found.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
defaultValue: Double |
The default value if the associated value is not found. |
| Returns | |
|---|---|
Double |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getDoubleArray
fun getDoubleArray(key: String): DoubleArray?
Retrieves a DoubleArray value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
DoubleArray? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getFloat
fun getFloat(key: String): Float
Retrieves a Float value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
Float |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getFloat
fun getFloat(key: String, defaultValue: Float): Float
Retrieves a Float value associated with the specified key, or returns defaultValue if the associated value is not found.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
defaultValue: Float |
The default value if the associated value is not found. |
| Returns | |
|---|---|
Float |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getFloatArray
fun getFloatArray(key: String): FloatArray?
Retrieves a FloatArray value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
FloatArray? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getInt
fun getInt(key: String): Int
Retrieves an Int value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
Int |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getInt
fun getInt(key: String, defaultValue: Int): Int
Retrieves an Int value associated with the specified key, or returns defaultValue if the associated value is not found.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
defaultValue: Int |
The default value if the associated value is not found. |
| Returns | |
|---|---|
Int |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getIntArray
fun getIntArray(key: String): IntArray?
Retrieves an IntArray value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getLong
fun getLong(key: String): Long
Retrieves a Long value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
Long |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getLong
fun getLong(key: String, defaultValue: Long): Long
Retrieves a Long value associated with the specified key, or returns defaultValue if the associated value is not found.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
defaultValue: Long |
The default value if the associated value is not found. |
| Returns | |
|---|---|
Long |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getLongArray
fun getLongArray(key: String): LongArray?
Retrieves a LongArray value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getParcelable
inline fun <T : Parcelable> getParcelable(key: String): T?
Retrieves a Parcelable value of type T associated with the specified key.
Returns null or fails with an exception if:
-
No value exists for the given
key. -
The object is not of type
T. -
The
Parcelableof typeTcannot be loaded by the app'sclassLoader.
For Parcelable types not defined by the Android platform (e.g., custom classes shared between agents and apps), forward and backward compatibility is not guaranteed by this library. Implementers are responsible for managing any compatibility and versioning concerns.
| Parameters | |
|---|---|
<T : Parcelable> |
The type of the |
key: String |
The key to retrieve the value for. |
getParcelable
fun <T : Parcelable> getParcelable(key: String, clazz: Class<T>): T?
Retrieves a Parcelable value of type T associated with the specified key.
Returns null or fails with an exception if:
-
No value exists for the given
key. -
The object is not of type
clazz. -
The
Parcelableof typeTcannot be loaded by the app'sclassLoader.
For Parcelable types not defined by the Android platform (e.g., custom classes shared between agents and apps), forward and backward compatibility is not guaranteed by this library. Implementers are responsible for managing any compatibility and versioning concerns.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
clazz: Class<T> |
The |
getParcelableList
inline fun <T : Parcelable> getParcelableList(key: String): List<T>?
Retrieves a List of Parcelable values of type T associated with the specified key.
For Parcelable types not defined by the Android platform (e.g., custom classes shared between agents and apps), forward and backward compatibility is not guaranteed by this library. Implementers are responsible for managing any compatibility and versioning concerns.
| Parameters | |
|---|---|
<T : Parcelable> |
The type of the |
key: String |
The key to retrieve the list for. |
getParcelableList
fun <T : Parcelable> getParcelableList(key: String, clazz: Class<T>): List<T>?
Retrieves a List of Parcelable values of type T associated with the specified key.
For Parcelable types not defined by the Android platform (e.g., custom classes shared between agents and apps), forward and backward compatibility is not guaranteed by this library. Implementers are responsible for managing any compatibility and versioning concerns.
| Parameters | |
|---|---|
key: String |
The key to retrieve the list for. |
clazz: Class<T> |
The |
getPendingIntent
fun getPendingIntent(key: String): PendingIntent?
Retrieves a PendingIntent value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
PendingIntent? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getPendingIntentList
fun getPendingIntentList(key: String): List<PendingIntent>?
Retrieves a List of PendingIntent value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
List<PendingIntent>? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getString
fun getString(key: String): String?
Retrieves a String value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
getStringList
fun getStringList(key: String): List<String>?
Retrieves a List of String value associated with the specified key.
| Parameters | |
|---|---|
key: String |
The key to retrieve the value for. |
| Returns | |
|---|---|
List<String>? |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
Public properties
qualifiedName
val qualifiedName: String
Qualified name of the underlying object