• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AppStateData
2
3The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications).
4
5## Modules to Import
6
7```ts
8import appManager from '@ohos.app.ability.appManager';
9```
10
11**System capability**: SystemCapability.Ability.AbilityRuntime.Core
12
13**System API**: This is a system API and cannot be called by third-party applications.
14
15| Name                     | Type  | Mandatory | Description      |
16| ------------------------- | ------ | ---- | --------- |
17| bundleName<sup>8+</sup>   | string | No  | Bundle name.|
18| uid<sup>8+</sup>          | number | No  | User ID.  |
19| state<sup>8+</sup>        | number | No  | Application state.|
20
21**Example**
22```ts
23import appManager from "@ohos.application.appManager";
24
25appManager.getForegroundApplications((error, data) => {
26    for (let i = 0; i < data.length; i++) {
27        let appStateData = data[i];
28        console.info('appStateData.bundleName: ' + appStateData.bundleName);
29        console.info('appStateData.uid: ' + appStateData.uid);
30        console.info('appStateData.state: ' + appStateData.state);
31    }
32});
33```
34
35