1# @ohos.application.appManager (appManager) 2 3The **appManager** module implements application management. You can use the APIs of this module to query whether the application is undergoing a stability test, whether the application is running on a RAM constrained device, the memory size of the application, and information about the running process. 4 5> **NOTE** 6> 7> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.appManager](js-apis-app-ability-appManager.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import appManager from '@ohos.application.appManager'; 13``` 14 15## appManager.isRunningInStabilityTest 16 17isRunningInStabilityTest(callback: AsyncCallback<boolean>): void 18 19Checks whether this application is undergoing a stability test. This API uses an asynchronous callback to return the result. 20 21**System capability**: SystemCapability.Ability.AbilityRuntime.Core 22 23**Parameters** 24 25 | Name| Type| Mandatory| Description| 26 | -------- | -------- | -------- | -------- | 27 | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.| 28 29**Example** 30 31 ```ts 32 import appManager from '@ohos.application.appManager'; 33 34 appManager.isRunningInStabilityTest((error, flag) => { 35 if (error && error.code !== 0) { 36 console.error(`isRunningInStabilityTest fail, error: ${JSON.stringify(error)}`); 37 } else { 38 console.log(`isRunningInStabilityTest success, the result is: ${JSON.stringify(flag)}`); 39 } 40 }); 41 ``` 42 43 44## appManager.isRunningInStabilityTest 45 46isRunningInStabilityTest(): Promise<boolean> 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<boolean> | Promise used to return the result. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.| 57 58**Example** 59 60 ```ts 61 import appManager from '@ohos.application.appManager'; 62 import { BusinessError } from '@ohos.base'; 63 64 appManager.isRunningInStabilityTest().then((flag) => { 65 console.log(`The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}`); 66 }).catch((error: BusinessError) => { 67 console.error(`error: ${JSON.stringify(error)}`); 68 }); 69 ``` 70 71 72## appManager.isRamConstrainedDevice<sup>7+<sup> 73 74isRamConstrainedDevice(): Promise\<boolean> 75 76Checks whether this application is running on a RAM constrained device. This API uses a promise to return the result. 77 78**System capability**: SystemCapability.Ability.AbilityRuntime.Core 79 80**Return value** 81 82 | Type| Description| 83 | -------- | -------- | 84 | Promise<boolean> | Promise used to return the result. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.| 85 86**Example** 87 88 ```ts 89 import appManager from '@ohos.application.appManager'; 90 import { BusinessError } from '@ohos.base'; 91 92 appManager.isRamConstrainedDevice().then((data) => { 93 console.log(`The result of isRamConstrainedDevice is: ${JSON.stringify(data)}`); 94 }).catch((error: BusinessError) => { 95 console.error(`error: ${JSON.stringify(error)}`); 96 }); 97 ``` 98 99## appManager.isRamConstrainedDevice<sup>7+<sup> 100 101isRamConstrainedDevice(callback: AsyncCallback\<boolean>): void 102 103Checks whether this application is running on a RAM constrained device. This API uses an asynchronous callback to return the result. 104 105**System capability**: SystemCapability.Ability.AbilityRuntime.Core 106 107**Parameters** 108 109 | Name| Type| Mandatory| Description| 110 | -------- | -------- | -------- | -------- | 111 | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.| 112 113**Example** 114 115 ```ts 116 import appManager from '@ohos.application.appManager'; 117 118 appManager.isRamConstrainedDevice((error, data) => { 119 if (error && error.code !== 0) { 120 console.error(`isRamConstrainedDevice fail, error: ${JSON.stringify(error)}`); 121 } else { 122 console.log(`The result of isRamConstrainedDevice is: ${JSON.stringify(data)}`); 123 } 124 }); 125 ``` 126 127## appManager.getAppMemorySize<sup>7+<sup> 128 129getAppMemorySize(): Promise\<number> 130 131Obtains the memory size of this application. This API uses a promise to return the result. 132 133**System capability**: SystemCapability.Ability.AbilityRuntime.Core 134 135**Return value** 136 137 | Type| Description| 138 | -------- | -------- | 139 | Promise<number> | Promise used to return the memory size, in MB. You can perform error processing or other custom processing based on the size. | 140 141**Example** 142 143 ```ts 144 import appManager from '@ohos.application.appManager'; 145 import { BusinessError } from '@ohos.base'; 146 147 appManager.getAppMemorySize().then((data) => { 148 console.log(`The size of app memory is: ${JSON.stringify(data)}`); 149 }).catch((error: BusinessError) => { 150 console.error(`error: ${JSON.stringify(error)}`); 151 }); 152 ``` 153 154## appManager.getAppMemorySize<sup>7+<sup> 155 156getAppMemorySize(callback: AsyncCallback\<number>): void 157 158Obtains the memory size of this application. This API uses an asynchronous callback to return the result. 159 160**System capability**: SystemCapability.Ability.AbilityRuntime.Core 161 162**Parameters** 163 164 | Name| Type| Mandatory| Description| 165 | -------- | -------- | -------- | -------- | 166 | callback | AsyncCallback<number> | Yes| Callback used to return the memory size, in MB. You can perform error processing or other custom processing based on the size. | 167 168**Example** 169 170 ```ts 171 import appManager from '@ohos.application.appManager'; 172 173 appManager.getAppMemorySize((error, data) => { 174 if (error && error.code !== 0) { 175 console.error(`getAppMemorySize fail, error: ${JSON.stringify(error)}`); 176 } else { 177 console.log(`The size of app memory is: ${JSON.stringify(data)}`); 178 } 179 }); 180 ``` 181## appManager.getProcessRunningInfos<sup>(deprecated)</sup> 182 183getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>> 184 185Obtains information about the running processes. This API uses a promise to return the result. 186 187> This API is deprecated since API version 9. You are advised to use [appManager.getRunningProcessInformation](js-apis-app-ability-appManager.md#appmanagergetrunningprocessinformation) instead. 188 189**Required permissions**: ohos.permission.GET_RUNNING_INFO (available only for system applications) 190 191**System capability**: SystemCapability.Ability.AbilityRuntime.Core 192 193**Return value** 194 195| Type| Description| 196| -------- | -------- | 197| Promise\<Array\<[ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)>> | Promise used to return the information about the running processes.| 198 199**Example** 200 201 ```ts 202 import appManager from '@ohos.application.appManager'; 203 import { BusinessError } from '@ohos.base'; 204 205 appManager.getProcessRunningInfos().then((data) => { 206 console.log(`The process running infos is: ${JSON.stringify(data)}`); 207 }).catch((error: BusinessError) => { 208 console.error(`error: ${JSON.stringify(error)}`); 209 }); 210 ``` 211 212## appManager.getProcessRunningInfos<sup>(deprecated)</sup> 213 214getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void 215 216Obtains information about the running processes. This API uses an asynchronous callback to return the result. 217 218> This API is deprecated since API version 9. You are advised to use [appManager.getRunningProcessInformation](js-apis-app-ability-appManager.md#appmanagergetrunningprocessinformation) instead. 219 220**Required permissions**: ohos.permission.GET_RUNNING_INFO (available only for system applications) 221 222**System capability**: SystemCapability.Ability.AbilityRuntime.Core 223 224**Parameters** 225 226| Name| Type| Mandatory| Description| 227| -------- | -------- | -------- | -------- | 228| callback | AsyncCallback\<Array\<[ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)>> | Yes| Callback used to return the information about the running processes.| 229 230**Example** 231 232 ```ts 233 import appManager from '@ohos.application.appManager'; 234 235 appManager.getProcessRunningInfos((error, data) => { 236 if (error && error.code !== 0) { 237 console.error(`getProcessRunningInfos fail, error: ${JSON.stringify(error)}`); 238 } else { 239 console.log(`getProcessRunningInfos success, data: ${JSON.stringify(data)}`); 240 } 241 }); 242 ``` 243