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.getBundleInfoForSelf](../apis-ability-kit/js-apis-bundleManager.md#bundlemanagergetbundleinfoforself) instead.
24
25**Atomic service API**: This API can be used in atomic services since API version 12.
26
27**System capability**: SystemCapability.ArkUI.ArkUI.Lite
28
29**Return value**
30
31| Type| Description|
32| -------- | -------- |
33| [AppResponse](#appresponse) | Application response information.|
34
35**Example**
36
37```ts
38import app, { AppResponse } from '@system.app'
39export default class Info {
40  getInfo() {
41    let info:AppResponse = app.getInfo()
42    console.log(JSON.stringify(info))
43  }
44}
45```
46
47### terminate
48
49static terminate(): void
50
51Terminates the current ability.
52
53This API is deprecated since API version 7. You are advised to use [@ohos.ability.featureAbility](../apis-ability-kit/js-apis-ability-featureAbility.md) instead.
54
55**Atomic service API**: This API can be used in atomic services since API version 12.
56
57**System capability**: SystemCapability.ArkUI.ArkUI.Lite
58
59**Example**
60
61```ts
62import app, { AppResponse } from '@system.app'
63export default class TerM {
64  terminate() {
65    app.terminate()
66  }
67}
68```
69### setImageCacheCount<sup>7+</sup>
70
71static setImageCacheCount(value: number): void
72
73Sets 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.
74
75**setImageCacheCount** takes effect only when used in [onPageShow](../apis-arkui/arkui-ts/ts-custom-component-lifecycle.md#onpageshow) or [aboutToAppear](../apis-arkui/arkui-ts/ts-custom-component-lifecycle.md#abouttoappear) on the page decorated by @Entry.
76
77The **setImageCacheCount**, **setImageRawDataCacheSize**, and **setImageFileCacheSize** APIs are not flexible and will not be further evolved in future developments. In light of this, consider using [ImageKnife](https://gitee.com/openharmony-tpc/ImageKnife) for more complex scenarios.
78
79**Atomic service API**: This API can be used in atomic services since API version 12.
80
81**System capability**: SystemCapability.ArkUI.ArkUI.Full
82
83**Parameters**
84
85| Name| Type| Mandatory| Description|
86| -------- | -------- | -------- | -------- |
87| value | number | Yes| Number of decoded images that are cached in the memory.|
88
89**Example**
90
91```ts
92// xxx.ets
93import app, { AppResponse } from '@system.app'
94
95@Entry
96@Component
97struct Index {
98  onPageShow() {
99    // Set the maximum number of decoded images that can be cached in the memory to 100.
100    app.setImageCacheCount(100)
101    console.info('Application onPageShow')
102  }
103  onDestroy() {
104    console.info('Application onDestroy')
105  }
106
107  build() {
108    Row(){
109      // xxxxxxxxxxxxx indicates the image address.
110      Image('xxxxxxxxxxxxx')
111        .width(200)
112        .height(50)
113    }.width('100%')
114  }
115}
116```
117
118### setImageRawDataCacheSize<sup>7+</sup>
119
120static setImageRawDataCacheSize(value: number): void
121
122Sets 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.
123
124**setImageRawDataCacheSize** takes effect only when used in [onPageShow](../apis-arkui/arkui-ts/ts-custom-component-lifecycle.md#onpageshow) or [aboutToAppear](../apis-arkui/arkui-ts/ts-custom-component-lifecycle.md#abouttoappear) on the page decorated by @Entry.
125
126**Atomic service API**: This API can be used in atomic services since API version 12.
127
128**System capability**: SystemCapability.ArkUI.ArkUI.Full
129
130**Parameters**
131
132| Name| Type| Mandatory| Description|
133| -------- | -------- | -------- | -------- |
134| value | number | Yes| Size of the image data cached before decoding, in bytes.|
135
136**Example**
137
138```ts
139// xxx.ets
140import app, { AppResponse } from '@system.app'
141
142@Entry
143@Component
144struct Index {
145  onPageShow() {
146    // 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).
147    app.setImageRawDataCacheSize(104857600)
148    console.info('Application onPageShow')
149  }
150  onDestroy() {
151    console.info('Application onDestroy')
152  }
153
154  build() {
155    Row(){
156      // xxxxxxxxxxxxx indicates the image address.
157      Image('xxxxxxxxxxxxx')
158        .width(200)
159        .height(50)
160    }.width('100%')
161  }
162}
163```
164
165### setImageFileCacheSize<sup>7+</sup>
166
167static setImageFileCacheSize(value: number): void
168
169Sets 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. 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.
170
171**Atomic service API**: This API can be used in atomic services since API version 12.
172
173**System capability**: SystemCapability.ArkUI.ArkUI.Full
174
175**Parameters**
176
177| Name| Type| Mandatory| Description|
178| -------- | -------- | -------- | -------- |
179| value | number | Yes| Size of the image file cache, in bytes.|
180
181**Example**
182
183```ts
184// app.ets
185import app, { AppResponse } from '@system.app'
186
187export default class OnC {
188  onCreate() {
189    app.setImageFileCacheSize(209715200)
190    // Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB).
191    console.info('Application onCreate')
192  }
193  onDestroy() {
194    console.info('Application onDestroy')
195  }
196}
197```
198
199### ScreenOnVisible<sup>(deprecated)</sup>
200
201static screenOnVisible(options?: ScreenOnVisibleOptions): void
202
203Defines whether to keep the application visible when the screen is woken up.
204
205This API is deprecated since API version 8.
206
207**System capability**: SystemCapability.ArkUI.ArkUI.Full
208
209| Name   | Type                                             | Mandatory| Description                                                        |
210| ------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
211| 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.|
212
213### requestFullWindow<sup>(deprecated)</sup>
214
215static requestFullWindow(options?: RequestFullWindowOptions): void
216
217Requests 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.
218
219You are advised to use [@ohos.window](js-apis-window.md) since API version 7.
220
221**System capability**: SystemCapability.ArkUI.ArkUI.Full
222
223**Parameters**
224
225| Name | Type                                                 | Mandatory| Description                                                        |
226| ------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
227| 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.|
228
229**Example**
230
231```ts
232import app, { AppResponse } from '@system.app'
233export default class Req {
234  requestFullWindow() {
235    app.requestFullWindow({
236      duration: 200
237    })
238  }
239}
240```
241
242## AppResponse
243
244Defines the application response information.
245
246**Atomic service API**: This API can be used in atomic services since API version 12.
247
248**System capability**: The items in the table below require different system capabilities. For details, see the table.
249
250| Name| Type| Mandatory| Description|
251| -------- | -------- | -------- |-------- |
252| appID<sup>6+</sup> | string | Yes| Bundle name of an application. It uniquely identifies the application.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Full|
253| appName | string | Yes| Application name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite|
254| versionName | string | Yes| Application version name.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite|
255| versionCode | number | Yes| Application version number.<br> **System capability**: SystemCapability.ArkUI.ArkUI.Lite|
256
257## ScreenOnVisibleOptions
258
259Defines the options of the visible interface on the screen.
260
261**System capability**: SystemCapability.ArkUI.ArkUI.Full
262
263| Name| Type| Mandatory| Description|
264| -------- | -------- | -------- | -------- |
265| visible | boolean | No| Whether to keep the application visible. The default value is **false**.|
266| success | () => void | No| Callback upon success.|
267| fail | (data: string, code: number) => void | No| Callback upon failure.|
268| complete | () => void | No| Called when the API call is complete.|
269
270## RequestFullWindowOptions
271
272Defines the options of the **RequestFullWindow** API.
273
274**System capability**: SystemCapability.ArkUI.ArkUI.Full
275
276| Name| Type| Mandatory| Description|
277| -------- | -------- | -------- | -------- |
278| duration | number | Yes| Duration of an animation, in milliseconds.|
279