AppFunctionService.OnExecuteFunction 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在调用后 AppFunctionManager#executeAppFunction 由系统调用,该调用面向与此服务关联的 XML 资产引用的应用函数标识符。
[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
参数
- request
- ExecuteAppFunctionRequest
函数执行请求。
- callingPackage
- String
请求执行的应用的包名称。 强烈建议不要基于此值更改函数的行为。
函数应对所有调用方保持一致的行为,以确保可预测的体验。 从开始 android.os.Build.VERSION_CODES#CINNAMON_BUN,该值始终为空字符串。
- callingPackageSigningInfo
- SigningInfo
请求执行的应用的签名信息。 强烈建议不要基于此值更改函数的行为。 函数应对所有调用方保持一致的行为,以确保可预测的体验。 从 android.os.Build.VERSION_CODES#CINNAMON_BUN开始,该值将始终是未知的签名信息。
- cancellationSignal
- CancellationSignal
取消执行的信号。
- callback
- IOutcomeReceiver
用于报告结果或错误的回调。
- 特性
注解
系统调用以执行特定的应用函数。
此方法是处理应用中所有应用函数请求的入口点。 当系统需要 AppFunctionService 执行函数时,它将调用此方法。
已注册的每个函数都由唯一标识符标识。 此标识符不需要全局唯一,但它必须在应用中是唯一的。 例如,订购食品的函数可以标识为“orderFood”。 在大多数情况下,此标识符由 AppFunctions SDK 自动生成。
可以通过调用 ExecuteAppFunctionRequest#getFunctionIdentifier()确定要执行的函数。 这样,服务就可以将传入请求路由到处理特定函数的适当逻辑。
此方法始终在主线程中触发。 应在工作线程上运行繁重的任务,并使用给定的回调调度结果。 无论执行是否成功,都应始终使用回调报告结果。
如果系统请求,此方法还接受 CancellationSignal 应用应侦听取消函数的执行。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。