AppFunctionManager
class AppFunctionManager
kotlin.Any | |
↳ | android.app.appfunctions.AppFunctionManager |
Provides app functions related functionalities.
App function is a specific piece of functionality that an app offers to the system. These functionalities can be integrated into various system features.
Summary
Constants | |
---|---|
static Int |
The default state of the app function. |
static Int |
The app function is disabled. |
static Int |
The app function is enabled. |
Public methods | |
---|---|
Unit |
executeAppFunction(request: ExecuteAppFunctionRequest, executor: Executor, cancellationSignal: CancellationSignal, callback: Consumer<ExecuteAppFunctionResponse!>) Executes the app function. |
Unit |
isAppFunctionEnabled(functionIdentifier: String, targetPackage: String, executor: Executor, callback: OutcomeReceiver<Boolean!, Exception!>) Returns a boolean through a callback, indicating whether the app function is enabled. |
Unit |
setAppFunctionEnabled(functionIdentifier: String, newEnabledState: Int, executor: Executor, callback: OutcomeReceiver<Void!, Exception!>) Sets the enabled state of the app function owned by the calling package. |
Constants
APP_FUNCTION_STATE_DEFAULT
static val APP_FUNCTION_STATE_DEFAULT: Int
The default state of the app function. Call setAppFunctionEnabled
with this to reset enabled state to the default value.
Value: 0
APP_FUNCTION_STATE_DISABLED
static val APP_FUNCTION_STATE_DISABLED: Int
The app function is disabled. To disable an app function, call setAppFunctionEnabled
with this value.
Value: 2
APP_FUNCTION_STATE_ENABLED
static val APP_FUNCTION_STATE_ENABLED: Int
The app function is enabled. To enable an app function, call setAppFunctionEnabled
with this value.
Value: 1
Public methods
executeAppFunction
fun executeAppFunction(
request: ExecuteAppFunctionRequest,
executor: Executor,
cancellationSignal: CancellationSignal,
callback: Consumer<ExecuteAppFunctionResponse!>
): Unit
Executes the app function.
Note: Applications can execute functions they define. To execute functions defined in another component, apps would need to have android.permission.EXECUTE_APP_FUNCTIONS_TRUSTED
or android.permission.EXECUTE_APP_FUNCTIONS
.
Parameters | |
---|---|
request |
ExecuteAppFunctionRequest: the request to execute the app function This value cannot be null . |
executor |
Executor: the executor to run the callback This value cannot be null . Callback and listener events are dispatched through this Executor , providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor() . Otherwise, provide an Executor that dispatches to an appropriate thread. |
cancellationSignal |
CancellationSignal: the cancellation signal to cancel the execution. This value cannot be null . |
callback |
Consumer<ExecuteAppFunctionResponse!>: the callback to receive the function execution result. if the calling app does not own the app function or does not have android.permission.EXECUTE_APP_FUNCTIONS_TRUSTED or android.permission.EXECUTE_APP_FUNCTIONS , the execution result will contain ExecuteAppFunctionResponse.RESULT_DENIED . This value cannot be null . |
isAppFunctionEnabled
fun isAppFunctionEnabled(
functionIdentifier: String,
targetPackage: String,
executor: Executor,
callback: OutcomeReceiver<Boolean!, Exception!>
): Unit
Returns a boolean through a callback, indicating whether the app function is enabled.
* This method can only check app functions owned by the caller, or those where the caller has visibility to the owner package and holds either the android.Manifest.permission#EXECUTE_APP_FUNCTIONS or android.Manifest.permission#EXECUTE_APP_FUNCTIONS_TRUSTED permission.
If operation fails, the callback's OutcomeReceiver.onError
is called with errors:
IllegalArgumentException
, if the function is not found or the caller does not have access to it.
Parameters | |
---|---|
functionIdentifier |
String: the identifier of the app function to check (unique within the target package) and in most cases, these are automatically generated by the AppFunctions SDK This value cannot be null . |
targetPackage |
String: the package name of the app function's owner This value cannot be null . |
executor |
Executor: the executor to run the request This value cannot be null . |
callback |
OutcomeReceiver<Boolean!, Exception!>: the callback to receive the function enabled check result This value cannot be null . |
setAppFunctionEnabled
fun setAppFunctionEnabled(
functionIdentifier: String,
newEnabledState: Int,
executor: Executor,
callback: OutcomeReceiver<Void!, Exception!>
): Unit
Sets the enabled state of the app function owned by the calling package.
If operation fails, the callback's OutcomeReceiver.onError
is called with errors:
IllegalArgumentException
, if the function is not found or the caller does not have access to it.
Parameters | |
---|---|
functionIdentifier |
String: the identifier of the app function to enable (unique within the calling package). In most cases, identifiers are automatically generated by the AppFunctions SDK This value cannot be null . |
newEnabledState |
Int: the new state of the app function Value is android.app.appfunctions.AppFunctionManager#APP_FUNCTION_STATE_DEFAULT , android.app.appfunctions.AppFunctionManager#APP_FUNCTION_STATE_ENABLED , or android.app.appfunctions.AppFunctionManager#APP_FUNCTION_STATE_DISABLED |
executor |
Executor: the executor to run the callback This value cannot be null . |
callback |
OutcomeReceiver<Void!, Exception!>: the callback to receive the result of the function enablement. The call was successful if no exception was thrown. This value cannot be null . |