Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# AppFunctionObserver

*** ** * ** ***

` public interface AppFunctionObserver `   
` `

|---|
| android.app.appfunctions.AppFunctionObserver |

<br />

*** ** * ** ***

Interface for observing changes to app functions provided to `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#observeAppFunctions(java.util.concurrent.Executor,%20android.app.appfunctions.AppFunctionObserver)`.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionObserver#onAppFunctionMetadataChanged(java.util.Set<java.lang.String>)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String> changedPackageNames) ` Called when changes occur to a package exposing app functions that may impact the state or metadata of its contained functions. |
| ` abstract void` | ` https://developer.android.com/reference/android/app/appfunctions/AppFunctionObserver#onAppFunctionStatesChanged(java.util.Set<android.app.appfunctions.AppFunctionName>)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/android/app/appfunctions/AppFunctionName> changedFunctionNames) ` Called when the runtime state of one or more app functions changes. |

## Public methods

### onAppFunctionMetadataChanged

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onAppFunctionMetadataChanged (Set<String> changedPackageNames)
```

Called when changes occur to a package exposing app functions that may impact the state or metadata of its contained functions.

This includes changes such as:

- The definition of a function metadata exposed by the package has changed (e.g, the parameters of the function have changed).
- All functions within the package are added or removed due to the package being installed or uninstalled.
- The package's `https://developer.android.com/reference/android/app/appfunctions/AppFunctionPackageMetadata` has been updated.

Upon receiving this notification, clients can call `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#searchAppFunctions(android.app.appfunctions.AppFunctionSearchSpec,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionMetadata>,java.lang.Exception>)` with `https://developer.android.com/reference/android/app/appfunctions/AppFunctionSearchSpec.Builder#setPackageNames(java.util.Set<java.lang.String>)` to retrieve the updated `https://developer.android.com/reference/android/app/appfunctions/AppFunctionMetadata` for affected functions.

Clients should call `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#getAppFunctionStates(java.util.List<android.app.appfunctions.AppFunctionName>,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionState>,java.lang.Exception>)` to retrieve the latest `https://developer.android.com/reference/android/app/appfunctions/AppFunctionState` for packages affected by these changes.

**Note:** If packages are reported to have changed but are not returned from `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#searchAppFunctions(android.app.appfunctions.AppFunctionSearchSpec,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionMetadata>,java.lang.Exception>)`, it means that the packages have been uninstalled or no longer have functions.

<br />

| Parameters ||
|---|---|
| `changedPackageNames` | `Set`: The names of the updated packages. This value cannot be `null`. <br /> |

### onAppFunctionStatesChanged

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onAppFunctionStatesChanged (Set<AppFunctionName> changedFunctionNames)
```

Called when the runtime state of one or more app functions changes.

Upon receiving this notification, clients can call `https://developer.android.com/reference/android/app/appfunctions/AppFunctionManager#getAppFunctionStates(java.util.List<android.app.appfunctions.AppFunctionName>,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.util.List<android.app.appfunctions.AppFunctionState>,java.lang.Exception>)` to retrieve the updated `https://developer.android.com/reference/android/app/appfunctions/AppFunctionState` for the affected functions.

<br />

| Parameters ||
|---|---|
| `changedFunctionNames` | `Set`: The set of `https://developer.android.com/reference/android/app/appfunctions/AppFunctionName`s for the functions whose state has changed. This value cannot be `null`. <br /> |