• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# appManager
2
3> **NOTE**
4>
5> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
6
7
8Implements application management.
9
10
11## Modules to Import
12
13
14```js
15import app from '@ohos.application.appManager';
16```
17
18
19## appManager.isRunningInStabilityTest<sup>8+</sup>
20
21static isRunningInStabilityTest(callback: AsyncCallback&lt;boolean&gt;): void
22
23Checks whether this application is undergoing a stability test. This API uses an asynchronous callback to return the result.
24
25**System capability**: SystemCapability.Ability.AbilityRuntime.Core
26
27**Parameters**
28
29| Name| Type| Mandatory| Description|
30| -------- | -------- | -------- | -------- |
31| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
32
33**Example**
34
35
36  ```js
37  import app from '@ohos.application.appManager';
38  app.isRunningInStabilityTest((err, flag) => {
39      console.log('startAbility result:' + JSON.stringify(err));
40  })
41  ```
42
43
44## appManager.isRunningInStabilityTest<sup>8+</sup>
45
46static isRunningInStabilityTest(): Promise&lt;boolean&gt;
47
48Checks whether this application is undergoing a stability test. This API uses a promise to return the result.
49
50**System capability**: SystemCapability.Ability.AbilityRuntime.Core
51
52**Return value**
53
54| Type| Description|
55| -------- | -------- |
56| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
57
58**Example**
59
60  ```js
61  import app from '@ohos.application.appManager';
62  app.isRunningInStabilityTest().then((flag) => {
63      console.log('success:' + JSON.stringify(flag));
64  }).catch((error) => {
65      console.log('failed:' + JSON.stringify(error));
66  });
67  ```
68
69
70## appManager.isRamConstrainedDevice
71
72isRamConstrainedDevice(): Promise\<boolean>;
73
74Checks whether this application is running on a RAM constrained device. This API uses a promise to return the result.
75
76**System capability**: SystemCapability.Ability.AbilityRuntime.Core
77
78**Return value**
79
80| Type| Description|
81| -------- | -------- |
82| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
83
84**Example**
85
86  ```js
87        app.isRamConstrainedDevicePromise().then((data) => {
88            console.log('success:' + JSON.stringify(data));
89        }).catch((error) => {
90            console.log('failed:' + JSON.stringify(error));
91        });
92  ```
93
94## appManager.isRamConstrainedDevice
95
96isRamConstrainedDevice(callback: AsyncCallback\<boolean>): void;
97
98Checks whether this application is running on a RAM constrained device. This API uses an asynchronous callback to return the result.
99
100**System capability**: SystemCapability.Ability.AbilityRuntime.Core
101
102**Parameters**
103
104| Name| Type| Mandatory| Description|
105| -------- | -------- | -------- | -------- |
106| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
107
108**Example**
109
110  ```js
111        app.isRamConstrainedDevicePromise((err, data) => {
112            console.log('startAbility result failed:' + JSON.stringify(err));
113            console.log('startAbility result success:' + JSON.stringify(data));
114        })
115  ```
116
117## appManager.getAppMemorySize
118
119getAppMemorySize(): Promise\<number>;
120
121Obtains the memory size of this application. This API uses a promise to return the result.
122
123**System capability**: SystemCapability.Ability.AbilityRuntime.Core
124
125**Return value**
126
127| Type| Description|
128| -------- | -------- |
129| Promise&lt;number&gt; | Size of the application memory.|
130
131**Example**
132
133  ```js
134        app.getAppMemorySize().then((data) => {
135            console.log('success:' + JSON.stringify(data));
136        }).catch((error) => {
137            console.log('failed:' + JSON.stringify(error));
138        });
139  ```
140
141## appManager.getAppMemorySize
142
143getAppMemorySize(callback: AsyncCallback\<number>): void;
144
145Obtains the memory size of this application. This API uses an asynchronous callback to return the result.
146
147**System capability**: SystemCapability.Ability.AbilityRuntime.Core
148
149**Parameters**
150
151| Name| Type| Mandatory| Description|
152| -------- | -------- | -------- | -------- |
153| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
154
155**Example**
156
157  ```js
158        app.getAppMemorySize((err, data) => {
159            console.log('startAbility result failed :' + JSON.stringify(err));
160            console.log('startAbility result success:' + JSON.stringify(data));
161        })
162  ```
163## appManager.getProcessRunningInfos<sup>8+</sup>
164
165getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
166
167Obtains information about the running processes. This API uses a promise to return the result.
168
169**System capability**: SystemCapability.Ability.AbilityRuntime.Core
170
171**Return value**
172
173| Type| Description|
174| -------- | -------- |
175| Promise\<Array\<ProcessRunningInfo>> | Promise used to return the process information.|
176
177**Example**
178
179  ```js
180        app.GetProcessRunningInfos().then((data) => {
181            console.log('success:' + JSON.stringify(data));
182        }).catch((error) => {
183            console.log('failed:' + JSON.stringify(error));
184        });
185  ```
186
187## appManager.getProcessRunningInfos<sup>8+</sup>
188
189getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void;
190
191Obtains information about the running processes. This API uses an asynchronous callback to return the result.
192
193**System capability**: SystemCapability.Ability.AbilityRuntime.Core
194
195**Parameters**
196
197| Name| Type| Mandatory| Description|
198| -------- | -------- | -------- | -------- |
199| callback | AsyncCallback\<Array\<ProcessRunningInfo>> | No| Callback used to return the process information.|
200
201**Example**
202
203  ```js
204        app.GetProcessRunningInfos((err, data) => {
205            console.log('startAbility result failed :' + JSON.stringify(err));
206            console.log('startAbility result success:' + JSON.stringify(data));
207        })
208  ```
209
210## ProcessRunningInfo
211
212**System capability**: SystemCapability.Ability.AbilityRuntime.Core
213
214| Name       | Readable/Writable| Type                | Mandatory| Description                                                        |
215| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
216| pid<sup>8+</sup>     | Read only    | number               | No  | Process ID.                               |
217| uid<sup>8+</sup>   | Read only    | number               | No  | User ID.|
218| processName<sup>8+</sup>  | Read only    | string               | No  | Process name.|
219| bundleNames<sup>8+</sup>          | Read only    | Array\<string>              | No  | **bundleName** array in the running processes.|
220