1# @system.app (Application Context) 2 3> **NOTE** 4> 5> The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. 6 7 8## Modules to Import 9 10 11```ts 12import app from '@system.app' 13``` 14 15## App 16 17### getInfo 18 19static getInfo(): AppResponse 20 21Obtains the declared information in the **config.json** file of an application. 22 23This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead. 24 25**System capability**: SystemCapability.ArkUI.ArkUI.Lite 26 27**Return value** 28 29| Type| Description| 30| -------- | -------- | 31| [AppResponse](#appresponse) | Application response information.| 32 33**Example** 34 35```ts 36export default { 37 getInfo() { 38 let info = app.getInfo() 39 console.log(JSON.stringify(info)) 40 } 41} 42``` 43 44### terminate 45 46static terminate(): void 47 48Terminates the current ability. 49 50You are advised to use [@ohos.ability.featureAbility](js-apis-ability-featureAbility.md) since API version 7. 51 52**System capability**: SystemCapability.ArkUI.ArkUI.Lite 53 54**Example** 55 56```ts 57export default { 58 terminate() { 59 app.terminate() 60 } 61} 62``` 63### setImageCacheCount<sup>7+</sup> 64 65static setImageCacheCount(value: number): void 66 67Sets the maximum number of decoded images that can be cached in the memory to speed up the loading of images from the same sources. If the input parameter is not set, the default value **0** is used, indicating that images are not cached. The built-in Least Recently Used (LRU) policy is used for caching. If the maximum number is exceeded, the images that have not been updated for the longest time will be removed. You are advised to set the parameter based on the application memory requirements. If the number of images is too large, the memory usage may be too high. 68 69**System capability**: SystemCapability.ArkUI.ArkUI.Full 70 71**Parameters** 72 73| Name| Type| Mandatory| Description| 74| -------- | -------- | -------- | -------- | 75| value | number | Yes| Number of decoded images that are cached in the memory.| 76 77**Example** 78 79```ts 80// app.ets 81import app from '@system.app' 82 83export default { 84 onCreate() { 85 app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. 86 console.info('Application onCreate') 87 }, 88 onDestroy() { 89 console.info('Application onDestroy') 90 }, 91} 92``` 93 94### setImageRawDataCacheSize<sup>7+</sup> 95 96static setImageRawDataCacheSize(value: number): void 97 98Sets the maximum size (in bytes) of the image data cached in the memory before decoding to speed up the loading of images from the same sources. If the input parameter is not set, the default value **0** is used, indicating that images are not cached. The LRU policy is used for caching. If the maximum size is exceeded, the images that have not been updated for the longest time will be removed. You are advised to set the parameter based on the application memory requirements. If the image cache is too large, the memory usage may be too high. 99 100**System capability**: SystemCapability.ArkUI.ArkUI.Full 101 102**Parameters** 103 104| Name| Type| Mandatory| Description| 105| -------- | -------- | -------- | -------- | 106| value | number | Yes| Size of the image data cached before decoding, in bytes.| 107 108**Example** 109 110```ts 111// app.ets 112import app from '@system.app' 113 114export default { 115 onCreate() { 116 app.setImageRawDataCacheSize(104857600) 117 // Set the upper limit of the memory for caching image data before decoding to 100 MB. (100 x 1024 x 1024 B =104857600 B = 100 MB). 118 console.info('Application onCreate') 119 }, 120 onDestroy() { 121 console.info('Application onDestroy') 122 }, 123} 124``` 125 126### setImageFileCacheSize<sup>7+</sup> 127 128static setImageFileCacheSize(value: number): void 129 130Sets the maximum size of the image file cache (in bytes) to speed up the loading of images from the same sources, especially online image sources and thumbnails. If the input parameter is not set, the default value 100 MB is used. The LRU policy is used for caching. If the maximum size is exceeded, the images that have not been updated for the longest time will be removed. You are advised to set the parameter based on the application memory requirements. If the image cache is too large, the disk usage may be too high. 131 132**System capability**: SystemCapability.ArkUI.ArkUI.Full 133 134**Parameters** 135 136| Name| Type| Mandatory| Description| 137| -------- | -------- | -------- | -------- | 138| value | number | Yes| Size of the image file cache, in bytes.| 139 140**Example** 141 142```ts 143// app.ets 144import app from '@system.app' 145 146export default { 147 onCreate() { 148 app.setImageFileCacheSize(209715200) 149 // Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB). 150 console.info('Application onCreate') 151 }, 152 onDestroy() { 153 console.info('Application onDestroy') 154 }, 155} 156``` 157 158### ScreenOnVisible<sup>(deprecated)</sup> 159 160static screenOnVisible(options?: ScreenOnVisibleOptions): void 161 162Defines whether to keep the application visible when the screen is woken up. 163 164This API is deprecated since API Version 8. 165 166**System capability**: SystemCapability.ArkUI.ArkUI.Full 167 168| Name | Type | Mandatory| Description | 169| ------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 170| options | [ScreenOnVisibleOptions](#screenonvisibleoptions) | No | With keep-alive, the system is prevented from returning to the home screen when the screen is locked, so that the application is visible when the screen is woken up.| 171 172### requestFullWindow<sup>(deprecated)</sup> 173 174static requestFullWindow(options?: RequestFullWindowOptions): void 175 176Requests the application to run in full window. You can call this API when the FA runs in a non-full window, for example, semi-modal FA. This API is invalid for an application already in full-window mode. 177 178You are advised to use [@ohos.window](js-apis-window.md) since API version 7. 179 180**System capability**: SystemCapability.ArkUI.ArkUI.Full 181 182**Parameters** 183 184| Name | Type | Mandatory| Description | 185| ------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | 186| options | [RequestFullWindowOptions](#requestfullwindowoptions) | No | Duration for transition from the non-full window to the full window, in milliseconds. By default, the value is in direct proportion to the distance between the non-full window and the full window.| 187 188**Example** 189 190```ts 191export default { 192 requestFullWindow() { 193 app.requestFullWindow({ 194 duration: 200 195 }) 196 } 197} 198``` 199 200## AppResponse 201 202Defines the application response information. 203 204**System capability**: The items in the table below require different system capabilities. For details, see the table. 205 206| Name| Type| Mandatory| Description| 207| -------- | -------- | -------- |-------- | 208| appID<sup>6+</sup> | string | Yes| Bundle name of an application. It uniquely identifies the application.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Full| 209| appName | string | Yes| Application name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| 210| versionName | string | Yes| Application version name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| 211| versionCode | number | Yes| Application version number.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| 212 213## ScreenOnVisibleOptions 214 215Defines the options of the visible interface on the screen. 216 217**System capability**: SystemCapability.ArkUI.ArkUI.Full 218 219| Name| Type| Mandatory| Description| 220| -------- | -------- | -------- | -------- | 221| visible | boolean | No| Whether to keep the application visible. The default value is **false**.| 222| success | () => void | No| Callback upon success.| 223| fail | (data: string, code: number) => void | No| Callback upon failure.| 224| complete | () => void | No| Called when the API call is complete.| 225 226## RequestFullWindowOptions 227 228Defines the options of the **RequestFullWindow** API. 229 230**System capability**: SystemCapability.ArkUI.ArkUI.Full 231 232| Name| Type| Mandatory| Description| 233| -------- | -------- | -------- | -------- | 234| duration | number | Yes| Duration of an animation, in milliseconds.| 235