Language

AppFunctionManager.ObserveAppFunctions Method

Definition

Registers an observer to monitor changes to app functions within packages that the caller can query.

[Android.Runtime.Register("observeAppFunctions", "(Ljava/util/concurrent/Executor;Landroid/app/appfunctions/AppFunctionObserver;)Landroid/app/appfunctions/AppFunctionObservation;", "", ApiSince=37)]
public Android.App.AppFunctions.IAppFunctionObservation ObserveAppFunctions(Java.Util.Concurrent.IExecutor executor, Android.App.AppFunctions.IAppFunctionObserver appFunctionObserver);
[<Android.Runtime.Register("observeAppFunctions", "(Ljava/util/concurrent/Executor;Landroid/app/appfunctions/AppFunctionObserver;)Landroid/app/appfunctions/AppFunctionObservation;", "", ApiSince=37)>]
member this.ObserveAppFunctions : Java.Util.Concurrent.IExecutor * Android.App.AppFunctions.IAppFunctionObserver -> Android.App.AppFunctions.IAppFunctionObservation

Parameters

executor
IExecutor

the executor to run the AppFunctionObserver callbacks. 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.

appFunctionObserver
IAppFunctionObserver

the observer to receive updates to registered app functions. This value cannot be null.

Returns

An AppFunctionObservation used to cancel this observation. This value cannot be null.

Attributes

Remarks

Registers an observer to monitor changes to app functions within packages that the caller can query.

The caller should retain a reference to the returned AppFunctionObservation, and call AppFunctionObservation.cancel when observation is no longer required.

The callback is only triggered by changes after its registration. Any changes that occur before the registration are not reported.

An example usage flow is: Call observeAppFunctions(Executor, AppFunctionObserver), to start monitoring app function changes, using the AppFunctionObserver; Call searchAppFunctions(AppFunctionSearchSpec, Executor, OutcomeReceiver) and getAppFunctionStates(List, Executor, OutcomeReceiver) to get the initial list of app functions and their states; In AppFunctionObserver.onAppFunctionMetadataChanged, call searchAppFunctions(AppFunctionSearchSpec, Executor, OutcomeReceiver) with a AppFunctionSearchSpec that matches the changed packages to get the updated metadata; In AppFunctionObserver.onAppFunctionStatesChanged, call getAppFunctionStates(List, Executor, OutcomeReceiver) with the list of AppFunctionNames that matches the changed functions to get the updated states. Note that this is guaranteed to trigger after AppFunctionObserver.onAppFunctionMetadataChanged for new functions or functions that also changed states, so there's no need to call getAppFunctionStates(List, Executor, OutcomeReceiver) in AppFunctionObserver.onAppFunctionMetadataChanged.

Android reference for android.app.appfunctions.AppFunctionManager.observeAppFunctions.

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.

Applies to