語言

AppFunctionService.OnExecuteFunction 方法

定義

系統在呼叫 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 應用程式應監聽以在系統請求時取消該函式執行。

Java 文件 android.app.appfunctions.AppFunctionService.onExecuteFunction(android.app.appfunctions.ExecuteAppFunctionRequest, java.lang.String, android.content.pm.SigningInfo, android.os.CancellationSignal, android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse, android.app.appfunctions.AppFunctionException>)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於