AppFunctionManager
public
final
class
AppFunctionManager
extends Object
java.lang.Object | |
↳ | 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 | |
---|---|
int |
APP_FUNCTION_STATE_DEFAULT
The default state of the app function. |
int |
APP_FUNCTION_STATE_DISABLED
The app function is disabled. |
int |
APP_FUNCTION_STATE_ENABLED
The app function is enabled. |
Public methods | |
---|---|
void
|
executeAppFunction(ExecuteAppFunctionRequest request, Executor executor, CancellationSignal cancellationSignal, Consumer<ExecuteAppFunctionResponse> callback)
Executes the app function. |
void
|
isAppFunctionEnabled(String functionIdentifier, String targetPackage, Executor executor, OutcomeReceiver<Boolean, Exception> callback)
Returns a boolean through a callback, indicating whether the app function is enabled. |
void
|
setAppFunctionEnabled(String functionIdentifier, int newEnabledState, Executor executor, OutcomeReceiver<Void, Exception> callback)
Sets the enabled state of the app function owned by the calling package. |
Inherited methods | |
---|---|
Constants
APP_FUNCTION_STATE_DEFAULT
public static final int APP_FUNCTION_STATE_DEFAULT
The default state of the app function. Call setAppFunctionEnabled(String, int, Executor, OutcomeReceiver)
with this to reset
enabled state to the default value.
Constant Value: 0 (0x00000000)
APP_FUNCTION_STATE_DISABLED
public static final int APP_FUNCTION_STATE_DISABLED
The app function is disabled. To disable an app function, call setAppFunctionEnabled(String, int, Executor, OutcomeReceiver)
with this value.
Constant Value: 2 (0x00000002)
APP_FUNCTION_STATE_ENABLED
public static final int APP_FUNCTION_STATE_ENABLED
The app function is enabled. To enable an app function, call setAppFunctionEnabled(String, int, Executor, OutcomeReceiver)
with this value.
Constant Value: 1 (0x00000001)
Public methods
executeAppFunction
public void executeAppFunction (ExecuteAppFunctionRequest request, Executor executor, CancellationSignal cancellationSignal, Consumer<ExecuteAppFunctionResponse> callback)
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 : 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
public void isAppFunctionEnabled (String functionIdentifier, String targetPackage, Executor executor, OutcomeReceiver<Boolean, Exception> callback)
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 ERROR(/android.Manifest.permission#EXECUTE_APP_FUNCTIONS)
or ERROR(/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 : the callback to receive the function enabled check result
This value cannot be null . |
setAppFunctionEnabled
public void setAppFunctionEnabled (String functionIdentifier, int newEnabledState, Executor executor, OutcomeReceiver<Void, Exception> callback)
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 APP_FUNCTION_STATE_DEFAULT , APP_FUNCTION_STATE_ENABLED , or APP_FUNCTION_STATE_DISABLED |
executor |
Executor : the executor to run the callback
This value cannot be null . |
callback |
OutcomeReceiver : the callback to receive the result of the function enablement. The call was
successful if no exception was thrown.
This value cannot be null . |