1# AppForegroundStateObserver (System API)
2
3The AppForegroundStateObserver module defines the listener used to listen for application startup and exit state changes. It can be used as an input parameter of [on](js-apis-app-ability-appManager-sys.md#appmanageronappforegroundstate11) to listen for the state changes of all applications.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> The APIs provided by this module are system APIs.
9
10## Modules to Import
11
12```ts
13import { appManager } from '@kit.AbilityKit';
14```
15
16## Attributes
17
18**System API**: This is a system API.
19
20**System capability**: SystemCapability.Ability.AbilityRuntime.Core
21
22| Name                            | Type                   | Readable| Writable| Description  |
23| -------------------------------- | ---------------------- | ---- | ---- | ------------------ |
24| onAppStateChanged   | AsyncCallback\<void>   | Yes  | No  | Callback invoked when the startup or exit state of an application changes. The parameter type passed in is [AppStateData](js-apis-inner-application-appStateData.md).|
25
26**Example**
27```ts
28import { appManager } from '@kit.AbilityKit';
29
30let observer: appManager.AppForegroundStateObserver = {
31  onAppStateChanged(appStateData) {
32    console.log(`onAppStateChanged appStateData: ${JSON.stringify(appStateData)}`);
33  },
34};
35appManager.on('appForegroundState', observer);
36```
37