AppFunctionService.OnExecuteFunction Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Called by the system to execute a specific app function.
[Android.Runtime.Register("onExecuteFunction", "(Landroid/app/appfunctions/ExecuteAppFunctionRequest;Ljava/lang/String;Landroid/content/pm/SigningInfo;Landroid/os/CancellationSignal;Landroid/os/OutcomeReceiver;)V", "GetOnExecuteFunction_Landroid_app_appfunctions_ExecuteAppFunctionRequest_Ljava_lang_String_Landroid_content_pm_SigningInfo_Landroid_os_CancellationSignal_Landroid_os_OutcomeReceiver_Handler", ApiSince=36)]
public abstract void OnExecuteFunction(Android.App.AppFunctions.ExecuteAppFunctionRequest request, string callingPackage, Android.Content.PM.SigningInfo callingPackageSigningInfo, Android.OS.CancellationSignal cancellationSignal, Android.OS.IOutcomeReceiver callback);
[<Android.Runtime.Register("onExecuteFunction", "(Landroid/app/appfunctions/ExecuteAppFunctionRequest;Ljava/lang/String;Landroid/content/pm/SigningInfo;Landroid/os/CancellationSignal;Landroid/os/OutcomeReceiver;)V", "GetOnExecuteFunction_Landroid_app_appfunctions_ExecuteAppFunctionRequest_Ljava_lang_String_Landroid_content_pm_SigningInfo_Landroid_os_CancellationSignal_Landroid_os_OutcomeReceiver_Handler", ApiSince=36)>]
abstract member OnExecuteFunction : Android.App.AppFunctions.ExecuteAppFunctionRequest * string * Android.Content.PM.SigningInfo * Android.OS.CancellationSignal * Android.OS.IOutcomeReceiver -> unit
Parameters
- request
- ExecuteAppFunctionRequest
The function execution request.
- callingPackage
- String
The package name of the app that is requesting the execution.
- callingPackageSigningInfo
- SigningInfo
The signing information of the app that is requesting the execution.
- cancellationSignal
- CancellationSignal
A signal to cancel the execution.
- callback
- IOutcomeReceiver
A callback to report back the result or error.
- Attributes
Remarks
Called by the system to execute a specific app function.
This method is the entry point for handling all app function requests in an app. When the system needs your AppFunctionService to perform a function, it will invoke this method.
Each function you've registered is identified by a unique identifier. This identifier doesn't need to be globally unique, but it must be unique within your app. For example, a function to order food could be identified as "orderFood". In most cases, this identifier is automatically generated by the AppFunctions SDK.
You can determine which function to execute by calling ExecuteAppFunctionRequest#getFunctionIdentifier(). This allows your service to route the incoming request to the appropriate logic for handling the specific function.
This method is always triggered in the main thread. You should run heavy tasks on a worker thread and dispatch the result with the given callback. You should always report back the result using the callback, no matter if the execution was successful or not.
This method also accepts a CancellationSignal that the app should listen to cancel the execution of function if requested by the system.
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.