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, { AppResponse } 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](../apis-ability-kit/js-apis-bundleManager.md#bundlemanagergetbundleinfoforself) 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 36import app, { AppResponse } from '@system.app' 37export default class Info { 38 getInfo() { 39 let info:AppResponse = app.getInfo() 40 console.log(JSON.stringify(info)) 41 } 42} 43``` 44 45### terminate 46 47static terminate(): void 48 49Terminates the current ability. 50 51You are advised to use [@ohos.ability.featureAbility](../apis-ability-kit/js-apis-ability-featureAbility.md) since API version 7. 52 53**System capability**: SystemCapability.ArkUI.ArkUI.Lite 54 55**Example** 56 57```ts 58import app, { AppResponse } from '@system.app' 59export default class TerM { 60 terminate() { 61 app.terminate() 62 } 63} 64``` 65### setImageCacheCount<sup>7+</sup> 66 67static setImageCacheCount(value: number): void 68 69Sets 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. 70 71**System capability**: SystemCapability.ArkUI.ArkUI.Full 72 73**Parameters** 74 75| Name| Type| Mandatory| Description| 76| -------- | -------- | -------- | -------- | 77| value | number | Yes| Number of decoded images that are cached in the memory.| 78 79**Example** 80 81```ts 82// app.ets 83import app, { AppResponse } from '@system.app' 84 85export default class OnC { 86 onCreate() { 87 app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. 88 console.info('Application onCreate') 89 }, 90 onDestroy() { 91 console.info('Application onDestroy') 92 }, 93} 94``` 95 96### setImageRawDataCacheSize<sup>7+</sup> 97 98static setImageRawDataCacheSize(value: number): void 99 100Sets 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. 101 102**System capability**: SystemCapability.ArkUI.ArkUI.Full 103 104**Parameters** 105 106| Name| Type| Mandatory| Description| 107| -------- | -------- | -------- | -------- | 108| value | number | Yes| Size of the image data cached before decoding, in bytes.| 109 110**Example** 111 112```ts 113// app.ets 114import app, { AppResponse } from '@system.app' 115 116export default class OnC { 117 onCreate() { 118 app.setImageRawDataCacheSize(104857600) 119 // 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). 120 console.info('Application onCreate') 121 }, 122 onDestroy() { 123 console.info('Application onDestroy') 124 }, 125} 126``` 127 128### setImageFileCacheSize<sup>7+</sup> 129 130static setImageFileCacheSize(value: number): void 131 132Sets 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. 133 134**System capability**: SystemCapability.ArkUI.ArkUI.Full 135 136**Parameters** 137 138| Name| Type| Mandatory| Description| 139| -------- | -------- | -------- | -------- | 140| value | number | Yes| Size of the image file cache, in bytes.| 141 142**Example** 143 144```ts 145// app.ets 146import app, { AppResponse } from '@system.app' 147 148export default class OnC { 149 onCreate() { 150 app.setImageFileCacheSize(209715200) 151 // Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB). 152 console.info('Application onCreate') 153 }, 154 onDestroy() { 155 console.info('Application onDestroy') 156 }, 157} 158``` 159 160### ScreenOnVisible<sup>(deprecated)</sup> 161 162static screenOnVisible(options?: ScreenOnVisibleOptions): void 163 164Defines whether to keep the application visible when the screen is woken up. 165 166This API is deprecated since API Version 8. 167 168**System capability**: SystemCapability.ArkUI.ArkUI.Full 169 170| Name | Type | Mandatory| Description | 171| ------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 172| 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.| 173 174### requestFullWindow<sup>(deprecated)</sup> 175 176static requestFullWindow(options?: RequestFullWindowOptions): void 177 178Requests 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. 179 180You are advised to use [@ohos.window](js-apis-window.md) since API version 7. 181 182**System capability**: SystemCapability.ArkUI.ArkUI.Full 183 184**Parameters** 185 186| Name | Type | Mandatory| Description | 187| ------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | 188| 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.| 189 190**Example** 191 192```ts 193import app, { AppResponse } from '@system.app' 194export default class Req { 195 requestFullWindow() { 196 app.requestFullWindow({ 197 duration: 200 198 }) 199 } 200} 201``` 202 203## AppResponse 204 205Defines the application response information. 206 207**System capability**: The items in the table below require different system capabilities. For details, see the table. 208 209| Name| Type| Mandatory| Description| 210| -------- | -------- | -------- |-------- | 211| appID<sup>6+</sup> | string | Yes| Bundle name of an application. It uniquely identifies the application.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Full| 212| appName | string | Yes| Application name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| 213| versionName | string | Yes| Application version name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| 214| versionCode | number | Yes| Application version number.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite| 215 216## ScreenOnVisibleOptions 217 218Defines the options of the visible interface on the screen. 219 220**System capability**: SystemCapability.ArkUI.ArkUI.Full 221 222| Name| Type| Mandatory| Description| 223| -------- | -------- | -------- | -------- | 224| visible | boolean | No| Whether to keep the application visible. The default value is **false**.| 225| success | () => void | No| Callback upon success.| 226| fail | (data: string, code: number) => void | No| Callback upon failure.| 227| complete | () => void | No| Called when the API call is complete.| 228 229## RequestFullWindowOptions 230 231Defines the options of the **RequestFullWindow** API. 232 233**System capability**: SystemCapability.ArkUI.ArkUI.Full 234 235| Name| Type| Mandatory| Description| 236| -------- | -------- | -------- | -------- | 237| duration | number | Yes| Duration of an animation, in milliseconds.| 238<!--no_check-->