1e41f4b71Sopenharmony_ci# @ohos.app.ability.abilityManager (AbilityManager) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe AbilityManager module provides APIs for obtaining, adding, and updating ability running information and state information.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 
8e41f4b71Sopenharmony_ci> The APIs of this module are system APIs and cannot be called by third-party applications.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## AbilityState
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciEnumerates the ability states. This enum can be used together with [AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo-sys.md) to return the ability state. 
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**System API**: This is a system API.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci| Name| Value| Description| 
25e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
26e41f4b71Sopenharmony_ci| INITIAL | 0 | The ability is in the initial state.| 
27e41f4b71Sopenharmony_ci| FOCUS | 2 | The ability has the focus.|
28e41f4b71Sopenharmony_ci| FOREGROUND | 9 | The ability is in the foreground state. | 
29e41f4b71Sopenharmony_ci| BACKGROUND | 10 | The ability is in the background state. | 
30e41f4b71Sopenharmony_ci| FOREGROUNDING | 11 | The ability is in the state of being switched to the foreground. | 
31e41f4b71Sopenharmony_ci| BACKGROUNDING | 12 | The ability is in the state of being switched to the background. | 
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci## UserStatus<sup>12+</sup>
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciEnumerates the assertion result for different user operations.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**System API**: This is a system API.
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| Name| Value| Description|
42e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
43e41f4b71Sopenharmony_ci| ASSERT_TERMINATE | 0 | Assertion result of the terminate operation.|
44e41f4b71Sopenharmony_ci| ASSERT_CONTINUE | 1 | Assertion result of the continue operation.|
45e41f4b71Sopenharmony_ci| ASSERT_RETRY | 2 | Assertion result of the retry operation.|
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci## updateConfiguration
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ciupdateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciUpdates the configuration. This API uses an asynchronous callback to return the result.
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci**System API**: This is a system API.
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci**Permission required**: ohos.permission.UPDATE_CONFIGURATION
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
58e41f4b71Sopenharmony_ci 
59e41f4b71Sopenharmony_ci**Parameters**
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
62e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
63e41f4b71Sopenharmony_ci| config    | [Configuration](js-apis-app-ability-configuration.md)   | Yes   | New configuration. You only need to configure the items to be updated.|
64e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<void>                   | Yes   | Callback used to return the API call result. You can perform error handling or custom processing in it.     |
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci**Error codes**
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci| ID| Error Message|
71e41f4b71Sopenharmony_ci| ------- | -------- |
72e41f4b71Sopenharmony_ci| 201 | Permission denied. |
73e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
74e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
75e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**Example**
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci```ts
80e41f4b71Sopenharmony_ciimport { abilityManager, Configuration, ConfigurationConstant } from '@kit.AbilityKit';
81e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ciconst config: Configuration = {
84e41f4b71Sopenharmony_ci  language: 'Zh-Hans',                 // Simplified Chinese.
85e41f4b71Sopenharmony_ci  colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT,         // Light theme.
86e41f4b71Sopenharmony_ci  direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL,       // Vertical direction.
87e41f4b71Sopenharmony_ci  screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI,  // The screen pixel density is 'sdpi'.
88e41f4b71Sopenharmony_ci  displayId: 1,                        // The application is displayed on the display with ID 1.
89e41f4b71Sopenharmony_ci  hasPointerDevice: true,              // A pointer device is connected.
90e41f4b71Sopenharmony_ci};
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_citry {
93e41f4b71Sopenharmony_ci  abilityManager.updateConfiguration(config, (err: BusinessError) => {
94e41f4b71Sopenharmony_ci    if (err) {
95e41f4b71Sopenharmony_ci      console.error(`updateConfiguration fail, err: ${JSON.stringify(err)}`);
96e41f4b71Sopenharmony_ci    } else {
97e41f4b71Sopenharmony_ci      console.log('updateConfiguration success.');
98e41f4b71Sopenharmony_ci    }
99e41f4b71Sopenharmony_ci  });
100e41f4b71Sopenharmony_ci} catch (paramError) {
101e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
102e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
103e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
104e41f4b71Sopenharmony_ci}
105e41f4b71Sopenharmony_ci```
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci## updateConfiguration
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ciupdateConfiguration(config: Configuration): Promise\<void>
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ciUpdates the configuration. This API uses a promise to return the result.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**System API**: This is a system API.
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci**Permission required**: ohos.permission.UPDATE_CONFIGURATION
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**Parameters**
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
122e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
123e41f4b71Sopenharmony_ci| config    | [Configuration](js-apis-app-ability-configuration.md)   | Yes   | New configuration. You only need to configure the items to be updated.|
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**Return value**
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci| Type                                      | Description     |
128e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
129e41f4b71Sopenharmony_ci| Promise\<void> | Promise used to return the API call result. You can perform error handling or custom processing in it.|
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**Error codes**
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci| ID| Error Message|
136e41f4b71Sopenharmony_ci| ------- | -------- |
137e41f4b71Sopenharmony_ci| 201 | Permission denied. |
138e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
139e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
140e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**Example**
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci```ts
145e41f4b71Sopenharmony_ciimport { abilityManager, Configuration, ConfigurationConstant } from '@kit.AbilityKit';
146e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';;
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ciconst config: Configuration = {
149e41f4b71Sopenharmony_ci  language: 'Zh-Hans',                 // Simplified Chinese.
150e41f4b71Sopenharmony_ci  colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT,         // Light theme.
151e41f4b71Sopenharmony_ci  direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL,       // Vertical direction.
152e41f4b71Sopenharmony_ci  screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI,  // The screen pixel density is 'sdpi'.
153e41f4b71Sopenharmony_ci  displayId: 1,                        // The application is displayed on the display with ID 1.
154e41f4b71Sopenharmony_ci  hasPointerDevice: true,              // A pointer device is connected.
155e41f4b71Sopenharmony_ci};
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_citry {
158e41f4b71Sopenharmony_ci  abilityManager.updateConfiguration(config).then(() => {
159e41f4b71Sopenharmony_ci    console.log('updateConfiguration success.');
160e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
161e41f4b71Sopenharmony_ci    console.error(`updateConfiguration fail, err: ${JSON.stringify(err)}`);
162e41f4b71Sopenharmony_ci  });
163e41f4b71Sopenharmony_ci} catch (paramError) {
164e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
165e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
166e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
167e41f4b71Sopenharmony_ci}
168e41f4b71Sopenharmony_ci```
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci## getAbilityRunningInfos
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_cigetAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): void
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ciObtains the UIAbility running information. This API uses an asynchronous callback to return the result.
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**System API**: This is a system API.
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**Parameters**
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
185e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
186e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo-sys.md)>>  | Yes   | Callback used to return the API call result and the ability running information. You can perform error handling or custom processing in it.     |
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**Error codes**
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci| ID| Error Message|
193e41f4b71Sopenharmony_ci| ------- | -------- |
194e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
195e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
196e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci**Example**
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci```ts
201e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
202e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_citry {
205e41f4b71Sopenharmony_ci  abilityManager.getAbilityRunningInfos((err: BusinessError, data: Array<abilityManager.AbilityRunningInfo>) => {
206e41f4b71Sopenharmony_ci    if (err) {
207e41f4b71Sopenharmony_ci      console.error(`getAbilityRunningInfos fail, error: ${JSON.stringify(err)}`);
208e41f4b71Sopenharmony_ci    } else {
209e41f4b71Sopenharmony_ci      console.log(`getAbilityRunningInfos success, data: ${JSON.stringify(data)}`);
210e41f4b71Sopenharmony_ci    }
211e41f4b71Sopenharmony_ci  });
212e41f4b71Sopenharmony_ci} catch (paramError) {
213e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
214e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
215e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
216e41f4b71Sopenharmony_ci}
217e41f4b71Sopenharmony_ci```
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci## getAbilityRunningInfos
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_cigetAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ciObtains the UIAbility running information. This API uses a promise to return the result.
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci**System API**: This is a system API.
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**Return value**
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci| Type                                      | Description     |
234e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
235e41f4b71Sopenharmony_ci| Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo-sys.md)>> | Promise used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in it.|
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci**Error codes**
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci| ID| Error Message|
242e41f4b71Sopenharmony_ci| ------- | -------- |
243e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
244e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**Example**
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci```ts
249e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
250e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_citry {
253e41f4b71Sopenharmony_ci  abilityManager.getAbilityRunningInfos().then((data: Array<abilityManager.AbilityRunningInfo>) => {
254e41f4b71Sopenharmony_ci    console.log(`getAbilityRunningInfos success, data: ${JSON.stringify(data)}`);
255e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
256e41f4b71Sopenharmony_ci    console.error(`getAbilityRunningInfos fail, err: ${JSON.stringify(err)}`);
257e41f4b71Sopenharmony_ci  });
258e41f4b71Sopenharmony_ci} catch (paramError) {
259e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
260e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
261e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
262e41f4b71Sopenharmony_ci}
263e41f4b71Sopenharmony_ci```
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci## getExtensionRunningInfos
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_cigetExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ciObtains the ExtensionAbility running information. This API uses an asynchronous callback to return the result.
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci**System API**: This is a system API.
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**Parameters**
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
280e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
281e41f4b71Sopenharmony_ci| upperLimit | number                                   | Yes| Maximum number of messages that can be obtained. The maximum value is 2<sup>31</sup>-1.|
282e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo-sys.md)>>  | Yes   | Callback used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in it.     |
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci**Error codes**
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci| ID| Error Message|
289e41f4b71Sopenharmony_ci| ------- | -------- |
290e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
291e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
292e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci**Example**
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci```ts
297e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
298e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_cilet upperLimit = 10;
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_citry {
303e41f4b71Sopenharmony_ci  abilityManager.getExtensionRunningInfos(upperLimit, (err: BusinessError, data: Array<abilityManager.ExtensionRunningInfo>) => {
304e41f4b71Sopenharmony_ci    if (err) {
305e41f4b71Sopenharmony_ci      console.error(`getExtensionRunningInfos fail, err: ${JSON.stringify(err)}`);
306e41f4b71Sopenharmony_ci    } else {
307e41f4b71Sopenharmony_ci      console.log(`getExtensionRunningInfos success, data: ${JSON.stringify(data)}`);
308e41f4b71Sopenharmony_ci    }
309e41f4b71Sopenharmony_ci  });
310e41f4b71Sopenharmony_ci} catch (paramError) {
311e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
312e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
313e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
314e41f4b71Sopenharmony_ci}
315e41f4b71Sopenharmony_ci```
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci## getExtensionRunningInfos
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_cigetExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ciObtains the ExtensionAbility running information. This API uses a promise to return the result.
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci**System API**: This is a system API.
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**Parameters**
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
332e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
333e41f4b71Sopenharmony_ci| upperLimit | number                                   | Yes| Maximum number of messages that can be obtained. The maximum value is 2<sup>31</sup>-1.|
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci**Return value**
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci| Type                                      | Description     |
338e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
339e41f4b71Sopenharmony_ci| Promise\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo-sys.md)>> | Promise used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in it.|
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**Error codes**
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci| ID| Error Message|
346e41f4b71Sopenharmony_ci| ------- | -------- |
347e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
348e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
349e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci**Example**
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci```ts
354e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
355e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_cilet upperLimit = 10;
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_citry {
360e41f4b71Sopenharmony_ci  abilityManager.getExtensionRunningInfos(upperLimit).then((data: Array<abilityManager.ExtensionRunningInfo>) => {
361e41f4b71Sopenharmony_ci    console.log(`getExtensionRunningInfos success, data: ${JSON.stringify(data)}`);
362e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
363e41f4b71Sopenharmony_ci    console.error(`getExtensionRunningInfos fail, err: ${JSON.stringify(err)}`);
364e41f4b71Sopenharmony_ci  });
365e41f4b71Sopenharmony_ci} catch (paramError) {
366e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
367e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
368e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
369e41f4b71Sopenharmony_ci}
370e41f4b71Sopenharmony_ci```
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci## getTopAbility
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_cigetTopAbility(callback: AsyncCallback\<ElementName>): void
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ciObtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci**System API**: This is a system API.
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci**Parameters**
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
385e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
386e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)>  | Yes   | Callback used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in it.     |
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**Error codes**
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci| ID| Error Message|
393e41f4b71Sopenharmony_ci| ------- | -------- |
394e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
395e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
396e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci**Example**
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci```ts
401e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
402e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ciabilityManager.getTopAbility((err: BusinessError, data) => {
405e41f4b71Sopenharmony_ci  if (err) {
406e41f4b71Sopenharmony_ci    console.error(`getTopAbility fail, err: ${JSON.stringify(err)}`);
407e41f4b71Sopenharmony_ci  } else {
408e41f4b71Sopenharmony_ci    console.log(`getTopAbility success, data: ${JSON.stringify(data)}`);
409e41f4b71Sopenharmony_ci  }
410e41f4b71Sopenharmony_ci});
411e41f4b71Sopenharmony_ci```
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci## getTopAbility
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_cigetTopAbility(): Promise\<ElementName>
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ciObtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci**System API**: This is a system API.
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci**Return value**
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci| Type                                      | Description     |
426e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
427e41f4b71Sopenharmony_ci| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in it.|
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ci**Error codes**
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci| ID| Error Message|
434e41f4b71Sopenharmony_ci| ------- | -------- |
435e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
436e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci**Example**
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci```ts
441e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
442e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ciabilityManager.getTopAbility().then((data) => {
445e41f4b71Sopenharmony_ci  console.log(`getTopAbility success, data: ${JSON.stringify(data)}`);
446e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
447e41f4b71Sopenharmony_ci  console.error(`getTopAbility fail, err: ${JSON.stringify(err)}`);
448e41f4b71Sopenharmony_ci});
449e41f4b71Sopenharmony_ci```
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci## acquireShareData<sup>10+</sup>
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ciacquireShareData(missionId: number, callback: AsyncCallback\<Record\<string, Object>>): void
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ciCalled by a system dialog box to obtain shared data, which is set by the target UIAbility through **onShare()**. This API uses an asynchronous callback to return the result.
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci**System API**: This is a system API.
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ci**Parameters**
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
464e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
465e41f4b71Sopenharmony_ci| missionId | number                                   | Yes| Mission ID on the target application. The maximum value is 2<sup>31</sup>-1.|
466e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<Record\<string, Object>>  | Yes   | Callback used to return the API call result and the shared data. You can perform error handling or custom processing in it.     |
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**Error codes**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci| ID| Error Message|
473e41f4b71Sopenharmony_ci| ------- | -------- |
474e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
475e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
476e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci**Example**
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ci```ts
481e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
482e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_citry {
485e41f4b71Sopenharmony_ci  abilityManager.acquireShareData(1, (err: BusinessError, wantParam: Record<string, Object>) => {
486e41f4b71Sopenharmony_ci    if (err) {
487e41f4b71Sopenharmony_ci      console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`);
488e41f4b71Sopenharmony_ci    } else {
489e41f4b71Sopenharmony_ci      console.log(`acquireShareData success, data: ${JSON.stringify(wantParam)}`);
490e41f4b71Sopenharmony_ci    }
491e41f4b71Sopenharmony_ci  });
492e41f4b71Sopenharmony_ci} catch (paramError) {
493e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
494e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
495e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
496e41f4b71Sopenharmony_ci}
497e41f4b71Sopenharmony_ci```
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci## acquireShareData<sup>10+</sup>
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ciacquireShareData(missionId: number): Promise\<Record\<string, Object>>
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ciCalled by a system dialog box to obtain shared data, which is set by the target UIAbility through **onShare()**. This API uses a promise to return the result.
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci**System API**: This is a system API.
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ci**Parameters**
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
512e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
513e41f4b71Sopenharmony_ci| missionId | number                                   | Yes| Mission ID on the target application. The maximum value is 2<sup>31</sup>-1.|
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci**Return value**
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci| Type                                      | Description     |
518e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
519e41f4b71Sopenharmony_ci| Promise\<Record\<string, Object>>| Promise used to return the API call result and the shared data. You can perform error handling or custom processing in it.|
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci**Error codes**
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci| ID| Error Message|
526e41f4b71Sopenharmony_ci| ------- | -------- |
527e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
528e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
529e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci**Example**
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci```ts
534e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
535e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_citry {
538e41f4b71Sopenharmony_ci  abilityManager.acquireShareData(1).then((wantParam: Record<string, Object>) => {
539e41f4b71Sopenharmony_ci    console.log(`acquireShareData success, data: ${JSON.stringify(wantParam)}`);
540e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
541e41f4b71Sopenharmony_ci    console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`);
542e41f4b71Sopenharmony_ci  });
543e41f4b71Sopenharmony_ci} catch (paramError) {
544e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
545e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
546e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
547e41f4b71Sopenharmony_ci}
548e41f4b71Sopenharmony_ci```
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci## notifySaveAsResult<sup>10+</sup>
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_cinotifySaveAsResult(parameter: AbilityResult, requestCode: number, callback: AsyncCallback\<void>): void
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ciUsed by the [Data Loss Prevention (DLP)](../apis-data-protection-kit/js-apis-dlppermission.md) management application to notify a sandbox application of the data saving result. This API uses an asynchronous callback to return the result.
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ci**System API**: This is a system API.
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci**Parameters**
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
565e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
566e41f4b71Sopenharmony_ci| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Information returned to the initiator UIAbility.|
567e41f4b71Sopenharmony_ci| requestCode | number                                        | Yes| Request code passed in by the DLP management application.         |
568e41f4b71Sopenharmony_ci| callback  | AsyncCallback<void\>                             | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.        |
569e41f4b71Sopenharmony_ci
570e41f4b71Sopenharmony_ci**Error codes**
571e41f4b71Sopenharmony_ci
572e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
573e41f4b71Sopenharmony_ci
574e41f4b71Sopenharmony_ci| ID| Error Message|
575e41f4b71Sopenharmony_ci| ------- | -------- |
576e41f4b71Sopenharmony_ci| 201 | Permission denied. |
577e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
578e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
579e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci**Example**
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci```ts
584e41f4b71Sopenharmony_ciimport { abilityManager, Want, common } from '@kit.AbilityKit';
585e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_cilet want: Want = {
588e41f4b71Sopenharmony_ci  bundleName: 'com.example.myapplication',
589e41f4b71Sopenharmony_ci  abilityName: 'EntryAbility'
590e41f4b71Sopenharmony_ci};
591e41f4b71Sopenharmony_cilet resultCode = 100;
592e41f4b71Sopenharmony_ci// AbilityResult information returned to the initiator of the save-as behavior.
593e41f4b71Sopenharmony_cilet abilityResult: common.AbilityResult = {
594e41f4b71Sopenharmony_ci  want,
595e41f4b71Sopenharmony_ci  resultCode
596e41f4b71Sopenharmony_ci};
597e41f4b71Sopenharmony_cilet requestCode = 1;
598e41f4b71Sopenharmony_citry {
599e41f4b71Sopenharmony_ci  abilityManager.notifySaveAsResult(abilityResult, requestCode, (err: BusinessError) => {
600e41f4b71Sopenharmony_ci    if (err && err.code != 0) {
601e41f4b71Sopenharmony_ci      console.error(`notifySaveAsResult fail, err: ${JSON.stringify(err)}`);
602e41f4b71Sopenharmony_ci    } else {
603e41f4b71Sopenharmony_ci      console.log(`notifySaveAsResult success`);
604e41f4b71Sopenharmony_ci    }
605e41f4b71Sopenharmony_ci  });
606e41f4b71Sopenharmony_ci} catch (paramError) {
607e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
608e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
609e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
610e41f4b71Sopenharmony_ci}
611e41f4b71Sopenharmony_ci```
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ci## notifySaveAsResult<sup>10+</sup>
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_cinotifySaveAsResult(parameter: AbilityResult, requestCode: number): Promise\<void>
616e41f4b71Sopenharmony_ci
617e41f4b71Sopenharmony_ciUsed by the [Data Loss Prevention (DLP)](../apis-data-protection-kit/js-apis-dlppermission.md) management application to notify a sandbox application of the data saving result. This API uses a promise to return the result.
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_ci**System API**: This is a system API.
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
624e41f4b71Sopenharmony_ci
625e41f4b71Sopenharmony_ci**Parameters**
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
628e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
629e41f4b71Sopenharmony_ci| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Information returned to the initiator UIAbility.|
630e41f4b71Sopenharmony_ci| requestCode | number                                        | Yes| Request code passed in by the DLP management application.         |
631e41f4b71Sopenharmony_ci
632e41f4b71Sopenharmony_ci**Return value**
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci| Type                                      | Description     |
635e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
636e41f4b71Sopenharmony_ci| Promise<void\>| Promise that returns no value.|
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_ci**Error codes**
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci| ID| Error Message|
643e41f4b71Sopenharmony_ci| ------- | -------- |
644e41f4b71Sopenharmony_ci| 201 | Permission denied. |
645e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
646e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
647e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci**Example**
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci```ts
652e41f4b71Sopenharmony_ciimport { abilityManager, Want, common } from '@kit.AbilityKit';
653e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_cilet want: Want = {
656e41f4b71Sopenharmony_ci  bundleName: 'com.example.myapplication',
657e41f4b71Sopenharmony_ci  abilityName: 'EntryAbility'
658e41f4b71Sopenharmony_ci};
659e41f4b71Sopenharmony_cilet resultCode = 100;
660e41f4b71Sopenharmony_ci// AbilityResult information returned to the initiator of the save-as behavior.
661e41f4b71Sopenharmony_cilet abilityResult: common.AbilityResult = {
662e41f4b71Sopenharmony_ci  want,
663e41f4b71Sopenharmony_ci  resultCode
664e41f4b71Sopenharmony_ci};
665e41f4b71Sopenharmony_cilet requestCode = 1;
666e41f4b71Sopenharmony_citry {
667e41f4b71Sopenharmony_ci  abilityManager.notifySaveAsResult(abilityResult, requestCode).then(() => {
668e41f4b71Sopenharmony_ci    console.log(`notifySaveAsResult success`);
669e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
670e41f4b71Sopenharmony_ci    console.error(`notifySaveAsResult fail, err: ${JSON.stringify(err)}`);
671e41f4b71Sopenharmony_ci  });
672e41f4b71Sopenharmony_ci} catch (paramError) {
673e41f4b71Sopenharmony_ci  let code: number = (paramError as BusinessError).code;
674e41f4b71Sopenharmony_ci  let message: string = (paramError as BusinessError).message;
675e41f4b71Sopenharmony_ci  console.error(`error.code: ${code}, error.message: ${message}`);
676e41f4b71Sopenharmony_ci}
677e41f4b71Sopenharmony_ci```
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci## abilityManager.on('abilityForegroundState')<sup>11+</sup>
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_cion(type: 'abilityForegroundState', observer: AbilityForegroundStateObserver): void
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ciRegisters an observer to listen for ability start or exit events.
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ci**System API**: This is a system API.
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci**Parameters**
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
694e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
695e41f4b71Sopenharmony_ci| type | string | Yes| Event type. It is fixed at **'abilityForegroundState'**.|
696e41f4b71Sopenharmony_ci| observer | [AbilityForegroundStateObserver](js-apis-inner-application-abilityForegroundStateObserver-sys) | Yes| Observer used to listen for ability start or exit events.|
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci**Error codes**
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_ci| ID| Error Message|
703e41f4b71Sopenharmony_ci| ------- | -------- |
704e41f4b71Sopenharmony_ci| 201 | Permission denied. |
705e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
706e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
707e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ci**Example**
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci```ts
712e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
713e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_cilet observer: abilityManager.AbilityForegroundStateObserver = {
716e41f4b71Sopenharmony_ci  onAbilityStateChanged(abilityStateData) {
717e41f4b71Sopenharmony_ci    console.log(`onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
718e41f4b71Sopenharmony_ci  },
719e41f4b71Sopenharmony_ci};
720e41f4b71Sopenharmony_citry {
721e41f4b71Sopenharmony_ci  abilityManager.on('abilityForegroundState', observer);
722e41f4b71Sopenharmony_ci} catch (paramError) {
723e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
724e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
725e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
726e41f4b71Sopenharmony_ci}
727e41f4b71Sopenharmony_ci```
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ci## abilityManager.off('abilityForegroundState')<sup>11+</sup>
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_cioff(type: 'abilityForegroundState', observer?: AbilityForegroundStateObserver): void
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ciUnregisters the observer used to listen for ability start or exit events.
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci**System API**: This is a system API.
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_ci**Parameters**
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
744e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
745e41f4b71Sopenharmony_ci| type | string | Yes| Event type. It is fixed at **'abilityForegroundState'**.|
746e41f4b71Sopenharmony_ci| observer | [AbilityForegroundStateObserver](js-apis-inner-application-abilityForegroundStateObserver-sys) | No| Observer used to listen for ability start or exit events. If this parameter is not set, all observers associated with the specified event are deregistered. If this parameter is set, only the specified observer is deregistered.|
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci**Error codes**
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci| ID| Error Message|
753e41f4b71Sopenharmony_ci| ------- | -------- |
754e41f4b71Sopenharmony_ci| 201 | Permission denied. |
755e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
756e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
757e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ci**Example**
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ci```ts
762e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
763e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_cilet observer_: abilityManager.AbilityForegroundStateObserver | undefined;
766e41f4b71Sopenharmony_ci// 1. Register an observer to listen for ability start or exit events.
767e41f4b71Sopenharmony_cilet observer: abilityManager.AbilityForegroundStateObserver = {
768e41f4b71Sopenharmony_ci  onAbilityStateChanged(abilityStateData: abilityManager.AbilityStateData) {
769e41f4b71Sopenharmony_ci    console.log(`onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
770e41f4b71Sopenharmony_ci  },
771e41f4b71Sopenharmony_ci};
772e41f4b71Sopenharmony_citry {
773e41f4b71Sopenharmony_ci  abilityManager.on('abilityForegroundState', observer);
774e41f4b71Sopenharmony_ci  observer_ = observer;
775e41f4b71Sopenharmony_ci} catch (paramError) {
776e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
777e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
778e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
779e41f4b71Sopenharmony_ci}
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci// 2. Deregister the observer.
782e41f4b71Sopenharmony_citry {
783e41f4b71Sopenharmony_ci  abilityManager.off('abilityForegroundState',  observer_);
784e41f4b71Sopenharmony_ci} catch (paramError) {
785e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
786e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
787e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
788e41f4b71Sopenharmony_ci}
789e41f4b71Sopenharmony_ci```
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci## abilityManager.getForegroundUIAbilities<sup>11+</sup>
792e41f4b71Sopenharmony_ci
793e41f4b71Sopenharmony_cigetForegroundUIAbilities(callback: AsyncCallback\<Array\<AbilityStateData>>): void
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ciObtains the information about the UIAbilities of an application that is running in the foreground. This API uses an asynchronous callback to return the result.
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci**System API**: This is a system API.
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci**Parameters**
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
806e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
807e41f4b71Sopenharmony_ci  | callback | AsyncCallback\<Array\<[AbilityStateData](js-apis-inner-application-abilityStateData-sys.md)>>  | Yes|Callback used to return the API call result and the UIAbility information. You can perform error handling or custom processing in it.|
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci**Error codes**
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci| ID| Error Message|
814e41f4b71Sopenharmony_ci| ------- | -------- |
815e41f4b71Sopenharmony_ci| 201 | Permission denied. |
816e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
817e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
818e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci**Example**
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci```ts
823e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
824e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ciabilityManager.getForegroundUIAbilities((err: BusinessError, data: Array<abilityManager.AbilityStateData>) => {
827e41f4b71Sopenharmony_ci  if (err) {
828e41f4b71Sopenharmony_ci    console.error(`Get foreground ui abilities failed, error: ${JSON.stringify(err)}`);
829e41f4b71Sopenharmony_ci  } else {
830e41f4b71Sopenharmony_ci    console.log(`Get foreground ui abilities data is: ${JSON.stringify(data)}`);
831e41f4b71Sopenharmony_ci  }
832e41f4b71Sopenharmony_ci});
833e41f4b71Sopenharmony_ci```
834e41f4b71Sopenharmony_ci
835e41f4b71Sopenharmony_ci## abilityManager.getForegroundUIAbilities<sup>11+</sup>
836e41f4b71Sopenharmony_ci
837e41f4b71Sopenharmony_cigetForegroundUIAbilities(): Promise\<Array\<AbilityStateData>>
838e41f4b71Sopenharmony_ci
839e41f4b71Sopenharmony_ciObtains the information about the UIAbilities of an application that is running in the foreground. This API uses a promise to return the result.
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ci**System API**: This is a system API.
842e41f4b71Sopenharmony_ci
843e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_RUNNING_INFO
844e41f4b71Sopenharmony_ci
845e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
846e41f4b71Sopenharmony_ci
847e41f4b71Sopenharmony_ci**Return value**
848e41f4b71Sopenharmony_ci
849e41f4b71Sopenharmony_ci| Type| Description|
850e41f4b71Sopenharmony_ci| -------- | -------- |
851e41f4b71Sopenharmony_ci| Promise\<Array\<[AbilityStateData](js-apis-inner-application-abilityStateData-sys.md)>> | Promise used to return the API call result and the UIAbility information. You can perform error handling or custom processing in it.|
852e41f4b71Sopenharmony_ci
853e41f4b71Sopenharmony_ci**Error codes**
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ci| ID| Error Message|
858e41f4b71Sopenharmony_ci| ------- | -------- |
859e41f4b71Sopenharmony_ci| 201 | Permission denied. |
860e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
861e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ci**Example**
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci```ts
866e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
867e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
868e41f4b71Sopenharmony_ci
869e41f4b71Sopenharmony_ciabilityManager.getForegroundUIAbilities().then((data: Array<abilityManager.AbilityStateData>) => {
870e41f4b71Sopenharmony_ci  console.log(`Get foreground ui abilities data is: ${JSON.stringify(data)}`);
871e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
872e41f4b71Sopenharmony_ci  console.error(`Get foreground ui abilities failed, error: ${JSON.stringify(error)}`);
873e41f4b71Sopenharmony_ci});
874e41f4b71Sopenharmony_ci```
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci## abilityManager.notifyDebugAssertResult<sup>12+</sup>
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_cinotifyDebugAssertResult(sessionId: string, status: UserStatus): Promise\<void>
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ciNotifies the application of the assertion result. This API uses a promise to return the result.
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci**System API**: This is a system API.
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.NOTIFY_DEBUG_ASSERT_RESULT
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
887e41f4b71Sopenharmony_ci
888e41f4b71Sopenharmony_ci**Parameters**
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
891e41f4b71Sopenharmony_ci| ------- | -------- | -------- | -------- |
892e41f4b71Sopenharmony_ci| sessionId | string | Yes| Session ID of the AssertFault.|
893e41f4b71Sopenharmony_ci| status | [UserStatus](#userstatus12) | Yes| Assertion result of the user operation.|
894e41f4b71Sopenharmony_ci
895e41f4b71Sopenharmony_ci**Return value**
896e41f4b71Sopenharmony_ci
897e41f4b71Sopenharmony_ci| Type| Description|
898e41f4b71Sopenharmony_ci| -------- | -------- |
899e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
900e41f4b71Sopenharmony_ci
901e41f4b71Sopenharmony_ci**Error codes**
902e41f4b71Sopenharmony_ci
903e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ci| ID| Error Message|
906e41f4b71Sopenharmony_ci| ------- | -------- |
907e41f4b71Sopenharmony_ci| 201 | Permission denied. |
908e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
909e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
910e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
911e41f4b71Sopenharmony_ci
912e41f4b71Sopenharmony_ci**Example**
913e41f4b71Sopenharmony_ci
914e41f4b71Sopenharmony_ci```ts
915e41f4b71Sopenharmony_ciimport { abilityManager, UIExtensionAbility, wantConstant, Want, UIExtensionContentSession } from '@kit.AbilityKit';
916e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ciexport default class UiExtAbility extends UIExtensionAbility {
919e41f4b71Sopenharmony_ci  onSessionCreate(want: Want, session: UIExtensionContentSession): void {
920e41f4b71Sopenharmony_ci    let sessionId: string = '';
921e41f4b71Sopenharmony_ci    if (want.parameters) {
922e41f4b71Sopenharmony_ci      sessionId = want.parameters[wantConstant.Params.ASSERT_FAULT_SESSION_ID] as string;
923e41f4b71Sopenharmony_ci    }
924e41f4b71Sopenharmony_ci    let status = abilityManager.UserStatus.ASSERT_TERMINATE;
925e41f4b71Sopenharmony_ci    abilityManager.notifyDebugAssertResult(sessionId, status).then(() => {
926e41f4b71Sopenharmony_ci      console.log('notifyDebugAssertResult success.');
927e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
928e41f4b71Sopenharmony_ci      console.error(`notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`);
929e41f4b71Sopenharmony_ci    });
930e41f4b71Sopenharmony_ci  }
931e41f4b71Sopenharmony_ci}
932e41f4b71Sopenharmony_ci```
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_ci## abilityManager.isEmbeddedOpenAllowed<sup>12</sup>
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ciisEmbeddedOpenAllowed(context: Context, appId: string): Promise\<boolean>
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ciChecks whether the [EmbeddableUIAbility](js-apis-app-ability-embeddableUIAbility.md) can be started in embedded mode. This API uses a promise to return the result.
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci**System API**: This is a system API.
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
943e41f4b71Sopenharmony_ci
944e41f4b71Sopenharmony_ci**Parameters**
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
947e41f4b71Sopenharmony_ci| ------- | -------- | -------- | -------- |
948e41f4b71Sopenharmony_ci| context | [Context](js-apis-inner-application-context.md) | Yes| Context of the caller.|
949e41f4b71Sopenharmony_ci| appId | string | Yes| Unique ID of the application, which is allocated by the cloud.|
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci**Return value**
952e41f4b71Sopenharmony_ci
953e41f4b71Sopenharmony_ci| Type| Description|
954e41f4b71Sopenharmony_ci| -------- | -------- |
955e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return the result. The value **true** means that embedded startup is allowed, and **false** means the opposite.|
956e41f4b71Sopenharmony_ci
957e41f4b71Sopenharmony_ci**Error codes**
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
960e41f4b71Sopenharmony_ci
961e41f4b71Sopenharmony_ci| ID| Error Message|
962e41f4b71Sopenharmony_ci| ------- | -------- |
963e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
964e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_ci**Example**
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci```ts
969e41f4b71Sopenharmony_ciimport { abilityManager, UIAbility } from '@kit.AbilityKit';
970e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
973e41f4b71Sopenharmony_ci  onForeground() {
974e41f4b71Sopenharmony_ci    let appId: string = '6918661953712445909';
975e41f4b71Sopenharmony_ci    try {
976e41f4b71Sopenharmony_ci      abilityManager.isEmbeddedOpenAllowed(this.context, appId).then((data) => {
977e41f4b71Sopenharmony_ci        console.info(`isEmbeddedOpenAllowed data: ${JSON.stringify(data)}`);
978e41f4b71Sopenharmony_ci      }).catch((err: BusinessError) => {
979e41f4b71Sopenharmony_ci        console.error(`isEmbeddedOpenAllowed failed, code is ${err.code}, message is ${err.message}`);
980e41f4b71Sopenharmony_ci      });
981e41f4b71Sopenharmony_ci    } catch (err) {
982e41f4b71Sopenharmony_ci      // Process input parameter errors.
983e41f4b71Sopenharmony_ci      console.error(`param is invalid, code is ${err.code}, message is ${err.message}`);
984e41f4b71Sopenharmony_ci    }
985e41f4b71Sopenharmony_ci  }
986e41f4b71Sopenharmony_ci}
987e41f4b71Sopenharmony_ci```
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci## abilityManager.setResidentProcessEnabled<sup>12+</sup>
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_cisetResidentProcessEnabled(bundleName: string, enable: boolean): Promise\<void>
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ciEnables or disables the resident process of an application.
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci**System API**: This is a system API.
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci**Parameters**
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1002e41f4b71Sopenharmony_ci| ------- | -------- | -------- | -------- |
1003e41f4b71Sopenharmony_ci| bundleName | string | Yes| Bundle name of the resident process.|
1004e41f4b71Sopenharmony_ci| enable | boolean | Yes| Whether to enable or disable the resident process. The value **true** means to enable the resident process, and **false** means to disable the resident process.|
1005e41f4b71Sopenharmony_ci
1006e41f4b71Sopenharmony_ci**Return value**
1007e41f4b71Sopenharmony_ci
1008e41f4b71Sopenharmony_ci| Type| Description|
1009e41f4b71Sopenharmony_ci| -------- | -------- |
1010e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ci**Error codes**
1013e41f4b71Sopenharmony_ci
1014e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_ci| ID| Error Message|
1017e41f4b71Sopenharmony_ci| ------- | -------- |
1018e41f4b71Sopenharmony_ci| 202 | Not a system application. |
1019e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible cause: 1.Non empty package name needs to be provided, 2.The second parameter needs to provide a Boolean type setting value |
1020e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
1021e41f4b71Sopenharmony_ci| 16200006 | The caller application can only set the resident status of the configured process |
1022e41f4b71Sopenharmony_ci
1023e41f4b71Sopenharmony_ci**Example**
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_ci```ts
1026e41f4b71Sopenharmony_ciimport { abilityManager } from '@kit.AbilityKit';
1027e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_citry {
1030e41f4b71Sopenharmony_ci  let residentProcessBundleName: string = 'com.xxx.xxxxxx';
1031e41f4b71Sopenharmony_ci  let enable: boolean = false;
1032e41f4b71Sopenharmony_ci  abilityManager.setResidentProcessEnabled(residentProcessBundleName, enable)
1033e41f4b71Sopenharmony_ci    .then(() => {
1034e41f4b71Sopenharmony_ci      console.log('setResidentProcessEnabled success.');
1035e41f4b71Sopenharmony_ci    })
1036e41f4b71Sopenharmony_ci    .catch((err: BusinessError) => {
1037e41f4b71Sopenharmony_ci      console.error(`setResidentProcessEnabled fail, err: ${JSON.stringify(err)}`);
1038e41f4b71Sopenharmony_ci    });
1039e41f4b71Sopenharmony_ci} catch (err) {
1040e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
1041e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
1042e41f4b71Sopenharmony_ci  console.error(`setResidentProcessEnabled failed, code is ${code}, message is ${message}`);
1043e41f4b71Sopenharmony_ci}
1044e41f4b71Sopenharmony_ci```
1045