ExecuteAppFunctionResponse


public final class ExecuteAppFunctionResponse
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.appfunctions.ExecuteAppFunctionResponse


The response to an app function execution.

Summary

Constants

String PROPERTY_RETURN_VALUE

The name of the property that stores the function return value within the resultDocument.

int RESULT_APP_UNKNOWN_ERROR

An unknown error occurred while processing the call in the AppFunctionService.

int RESULT_CANCELLED

The operation was cancelled.

int RESULT_DENIED

The caller does not have the permission to execute an app function.

int RESULT_DISABLED

The caller tried to execute a disabled app function.

int RESULT_INTERNAL_ERROR

An internal error occurred within AppFunctionManagerService.

int RESULT_INVALID_ARGUMENT

The caller supplied invalid arguments to the call.

int RESULT_OK

The call was successful.

Inherited constants

Fields

public static final Creator<ExecuteAppFunctionResponse> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

String getErrorMessage()

Returns the error message associated with this result.

Bundle getExtras()

Returns the extras of the app function execution.

int getResultCode()

Returns one of the RESULT constants defined in ExecuteAppFunctionResponse.

GenericDocument getResultDocument()

Returns a generic document containing the return value of the executed function.

boolean isSuccess()

Returns true if getResultCode() equals RESULT_OK.

static ExecuteAppFunctionResponse newFailure(int resultCode, String errorMessage, Bundle extras)

Returns a failure response.

static ExecuteAppFunctionResponse newSuccess(GenericDocument resultDocument, Bundle extras)

Returns a successful response.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

PROPERTY_RETURN_VALUE

public static final String PROPERTY_RETURN_VALUE

The name of the property that stores the function return value within the resultDocument.

See GenericDocument.getProperty(String) for more information.

If the function returns void or throws an error, the resultDocument will be empty GenericDocument.

If the resultDocument is empty, GenericDocument.getProperty(String) will return null.

See getResultDocument() for more information on extracting the return value.

Constant Value: "returnValue"

RESULT_APP_UNKNOWN_ERROR

public static final int RESULT_APP_UNKNOWN_ERROR

An unknown error occurred while processing the call in the AppFunctionService.

Constant Value: 2 (0x00000002)

RESULT_CANCELLED

public static final int RESULT_CANCELLED

The operation was cancelled. Use this error code to report that a cancellation is done after receiving a cancellation signal.

Constant Value: 6 (0x00000006)

RESULT_DENIED

public static final int RESULT_DENIED

The caller does not have the permission to execute an app function.

Constant Value: 1 (0x00000001)

RESULT_DISABLED

public static final int RESULT_DISABLED

The caller tried to execute a disabled app function.

Constant Value: 5 (0x00000005)

RESULT_INTERNAL_ERROR

public static final int RESULT_INTERNAL_ERROR

An internal error occurred within AppFunctionManagerService.

This error may be considered similar to IllegalStateException

Constant Value: 3 (0x00000003)

RESULT_INVALID_ARGUMENT

public static final int RESULT_INVALID_ARGUMENT

The caller supplied invalid arguments to the call.

This error may be considered similar to IllegalArgumentException.

Constant Value: 4 (0x00000004)

RESULT_OK

public static final int RESULT_OK

The call was successful.

Constant Value: 0 (0x00000000)

Fields

CREATOR

public static final Creator<ExecuteAppFunctionResponse> CREATOR

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(android.os.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 CONTENTS_FILE_DESCRIPTOR

getErrorMessage

public String getErrorMessage ()

Returns the error message associated with this result.

If isSuccess() is true, the error message is always null.

Returns
String

getExtras

public Bundle getExtras ()

Returns the extras of the app function execution.

Returns
Bundle This value cannot be null.

getResultCode

public int getResultCode ()

Returns one of the RESULT constants defined in ExecuteAppFunctionResponse.

Returns
int Value is RESULT_OK, RESULT_DENIED, RESULT_APP_UNKNOWN_ERROR, RESULT_INTERNAL_ERROR, RESULT_INVALID_ARGUMENT, RESULT_DISABLED, or RESULT_CANCELLED

getResultDocument

public GenericDocument getResultDocument ()

Returns a generic document containing the return value of the executed function.

The PROPERTY_RETURN_VALUE key can be used to obtain the return value.

An empty document is returned if isSuccess() is false or if the executed function does not produce a return value.

Sample code for extracting the return value:

     GenericDocument resultDocument = response.getResultDocument();
     Object returnValue = resultDocument.getProperty(PROPERTY_RETURN_VALUE);
     if (returnValue != null) {
       // Cast returnValue to expected type, or use GenericDocument.getPropertyString,
       // GenericDocument.getPropertyLong etc.
       // Do something with the returnValue
     }
 

Returns
GenericDocument

isSuccess

public boolean isSuccess ()

Returns true if getResultCode() equals RESULT_OK.

Returns
boolean

newFailure

public static ExecuteAppFunctionResponse newFailure (int resultCode, 
                String errorMessage, 
                Bundle extras)

Returns a failure response.

Parameters
resultCode int: The result code of the app function execution. Value is RESULT_OK, RESULT_DENIED, RESULT_APP_UNKNOWN_ERROR, RESULT_INTERNAL_ERROR, RESULT_INVALID_ARGUMENT, RESULT_DISABLED, or RESULT_CANCELLED

errorMessage String: The error message associated with the result, if any. This value may be null.

extras Bundle: The additional metadata data relevant to this function execution response. This value may be null.

Returns
ExecuteAppFunctionResponse This value cannot be null.

newSuccess

public static ExecuteAppFunctionResponse newSuccess (GenericDocument resultDocument, 
                Bundle extras)

Returns a successful response.

Parameters
resultDocument GenericDocument: The return value of the executed function. This value cannot be null.

extras Bundle: The additional metadata data relevant to this function execution response. This value may be null.

Returns
ExecuteAppFunctionResponse This value cannot be null.

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 Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES