• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.applicationManager (Application Management)
2
3The **applicationManager** module provides application management capabilities, including adding, removing, and obtaining the applications that are forbidden to run.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - The APIs of this module can be used only in the stage model.
10>
11> - The APIs of this module can be called only by a device administrator application that is enabled. For details, see [MDM Kit Development](../../mdm/mdm-kit-guide.md). The [applicationManager.isAppKioskAllowed](#applicationmanagerisappkioskallowed20) API is available to all applications.
12>
13
14## Modules to Import
15
16```ts
17import { applicationManager } from '@kit.MDMKit';
18```
19
20## applicationManager.addDisallowedRunningBundlesSync
21
22addDisallowedRunningBundlesSync(admin: Want, appIds: Array\<string>, accountId?: number): void
23
24Adds the applications that are not allowed to run by the current or specified user.
25
26**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
27
28**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
29
30
31
32**Parameters**
33
34| Name   | Type                                                   | Mandatory| Description                                                        |
35| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
36| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
37| appIds    | Array&lt;string&gt;                                     | Yes  | IDs of the applications to add.                                  |
38| accountId | number                                                  | No  | User ID, which must be greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the user ID.<br> - If **accountId** is passed in, this API applies to the specified user.<br> - If **accountId** is not passed in, this API applies to the current user.|
39
40**Error codes**
41
42For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
43
44| ID| Error Message                                                    |
45| -------- | ------------------------------------------------------------ |
46| 9200001  | The application is not an administrator application of the device. |
47| 9200002  | The administrator application does not have permission to manage the device. |
48| 201      | Permission verification failed. The application does not have the permission required to call the API. |
49| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
50
51**Example**
52
53```ts
54import { Want } from '@kit.AbilityKit';
55
56let wantTemp: Want = {
57  bundleName: 'com.example.myapplication',
58  abilityName: 'EntryAbility',
59};
60let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
61
62try {
63  applicationManager.addDisallowedRunningBundlesSync(wantTemp, appIds);
64  console.info('Succeeded in adding disallowed running bundles.');
65} catch (err) {
66  console.error(`Failed to add disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
67}
68```
69
70## applicationManager.removeDisallowedRunningBundlesSync
71
72removeDisallowedRunningBundlesSync(admin: Want, appIds:  Array\<string>, accountId?: number): void
73
74Removes the applications that are not allowed to run by the current user or specified user.
75
76**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
77
78**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
79
80
81
82**Parameters**
83
84| Name   | Type                                                   | Mandatory| Description                                                        |
85| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
86| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
87| appIds    | Array&lt;string&gt;                                     | Yes  | IDs of the applications to add.                                  |
88| accountId | number                                                  | No  | User ID, which must be greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the user ID.<br> - If **accountId** is passed in, this API applies to the specified user.<br> - If **accountId** is not passed in, this API applies to the current user.|
89
90**Error codes**
91
92For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
93
94| ID| Error Message                                                    |
95| -------- | ------------------------------------------------------------ |
96| 9200001  | The application is not an administrator application of the device. |
97| 9200002  | The administrator application does not have permission to manage the device. |
98| 201      | Permission verification failed. The application does not have the permission required to call the API. |
99| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
100
101**Example**
102
103```ts
104import { Want } from '@kit.AbilityKit';
105
106let wantTemp: Want = {
107  bundleName: 'com.example.myapplication',
108  abilityName: 'EntryAbility',
109};
110let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
111
112try {
113  applicationManager.removeDisallowedRunningBundlesSync(wantTemp, appIds);
114  console.info('Succeeded in removing disallowed running bundles.');
115} catch (err) {
116  console.error(`Failed to remove disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
117}
118```
119
120## applicationManager.getDisallowedRunningBundlesSync
121
122getDisallowedRunningBundlesSync(admin: Want, accountId?: number): Array&lt;string>
123
124Obtains applications that are not allowed to run by the current user or specified user.
125
126**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
127
128**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
129
130
131
132**Parameters**
133
134| Name   | Type                                                   | Mandatory| Description                                                        |
135| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
136| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
137| accountId | number                                                  | No  | User ID, which must be greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the user ID.<br> - If **accountId** is passed in, this API applies to the specified user.<br> - If **accountId** is not passed in, this API applies to the current user.|
138
139**Return value**
140
141| Type               | Description                            |
142| ------------------- | -------------------------------- |
143| Array&lt;string&gt; | Applications that are not allowed to run by the current user or a specified user.|
144
145**Error codes**
146
147For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
148
149| ID| Error Message                                                    |
150| -------- | ------------------------------------------------------------ |
151| 9200001  | The application is not an administrator application of the device. |
152| 9200002  | The administrator application does not have permission to manage the device. |
153| 201      | Permission verification failed. The application does not have the permission required to call the API. |
154| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
155
156**Example**
157
158```ts
159import { Want } from '@kit.AbilityKit';
160
161let wantTemp: Want = {
162  bundleName: 'com.example.myapplication',
163  abilityName: 'EntryAbility',
164};
165
166try {
167  let result: Array<string> = applicationManager.getDisallowedRunningBundlesSync(wantTemp);
168  console.info(`Succeeded in getting disallowed running bundles, result : ${JSON.stringify(result)}`);
169} catch (err) {
170  console.error(`Failed to get disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
171}
172```
173
174## applicationManager.addAutoStartApps
175
176addAutoStartApps(admin: Want, autoStartApps: Array\<Want>): void
177
178Adds the auto-start applications. Currently, this capability supports only 2-in-1 devices.
179
180**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
181
182**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
183
184**Parameters**
185
186| Name       | Type                                                        | Mandatory| Description                                  |
187| ------------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
188| admin         | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes  | EnterpriseAdminExtensionAbility.                        |
189| autoStartApps | Array\<[Want](../apis-ability-kit/js-apis-app-ability-want.md)> | Yes  | Auto-start applications to add. The maximum array length is 10.|
190
191**Error codes**
192
193For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
194
195| ID| Error Message                                                    |
196| -------- | ------------------------------------------------------------ |
197| 9200001  | The application is not an administrator application of the device. |
198| 9200002  | The administrator application does not have permission to manage the device. |
199| 201      | Permission verification failed. The application does not have the permission required to call the API. |
200| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
201
202**Example**
203
204```ts
205import { Want } from '@kit.AbilityKit';
206
207let wantTemp: Want = {
208  bundleName: 'com.example.myapplication',
209  abilityName: 'EntryAbility',
210};
211let autoStartApps: Array<Want> = [
212  {
213    bundleName: 'com.example.autoStartApplication',
214    abilityName: 'EntryAbility',
215  }
216];
217
218try {
219  applicationManager.addAutoStartApps(wantTemp, autoStartApps);
220  console.info(`Succeeded in adding auto start applications.`);
221} catch(err) {
222  console.error(`Failed to add auto start applications. Code: ${err.code}, message: ${err.message}`);
223}
224```
225
226## applicationManager.removeAutoStartApps
227
228removeAutoStartApps(admin: Want, autoStartApps: Array\<Want>): void
229
230Removes the auto-start applications. Currently, this capability supports only 2-in-1 devices.
231
232**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
233
234**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
235
236**Parameters**
237
238| Name       | Type                                                        | Mandatory| Description            |
239| ------------- | ------------------------------------------------------------ | ---- | ---------------- |
240| admin         | [Want](../apis-ability-kit/js-apis-app-ability-want.md)      | Yes  | EnterpriseAdminExtensionAbility.  |
241| autoStartApps | Array\<[Want](../apis-ability-kit/js-apis-app-ability-want.md)> | Yes  | Auto-start applications to remove.|
242
243**Error codes**
244
245For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
246
247| ID| Error Message                                                    |
248| -------- | ------------------------------------------------------------ |
249| 9200001  | The application is not an administrator application of the device. |
250| 9200002  | The administrator application does not have permission to manage the device. |
251| 201      | Permission verification failed. The application does not have the permission required to call the API. |
252| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
253
254**Example**
255
256```ts
257import { Want } from '@kit.AbilityKit';
258
259let wantTemp: Want = {
260  bundleName: 'com.example.myapplication',
261  abilityName: 'EntryAbility',
262};
263let autoStartApps: Array<Want> = [
264  {
265    bundleName: 'com.example.autoStartApplication',
266    abilityName: 'EntryAbility',
267  }
268];
269
270try {
271  applicationManager.removeAutoStartApps(wantTemp, autoStartApps);
272  console.info(`Succeeded in removing auto start applications.`);
273} catch(err) {
274  console.error(`Failed to remove auto start applications. Code: ${err.code}, message: ${err.message}`);
275}
276```
277
278## applicationManager.getAutoStartApps
279
280getAutoStartApps(admin: Want): Array\<Want>
281
282Queries the auto-start applications. Currently, this capability supports only 2-in-1 devices.
283
284**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
285
286**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
287
288**Parameters**
289
290| Name| Type                                                   | Mandatory| Description          |
291| ------ | ------------------------------------------------------- | ---- | -------------- |
292| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.|
293
294**Return value**
295
296| Type                                                        | Description                |
297| ------------------------------------------------------------ | -------------------- |
298| Array\<[Want](../apis-ability-kit/js-apis-app-ability-want.md)> | List of the auto-start applications obtained.|
299
300**Error codes**
301
302For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
303
304| ID| Error Message                                                    |
305| -------- | ------------------------------------------------------------ |
306| 9200001  | The application is not an administrator application of the device. |
307| 9200002  | The administrator application does not have permission to manage the device. |
308| 201      | Permission verification failed. The application does not have the permission required to call the API. |
309| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
310
311**Example**
312
313```ts
314import { Want } from '@kit.AbilityKit';
315
316let wantTemp: Want = {
317  bundleName: 'com.example.myapplication',
318  abilityName: 'EntryAbility',
319};
320
321try {
322  let res: Array<Want> = applicationManager.getAutoStartApps(wantTemp);
323  console.info(`Succeeded in adding auto start apps: ${JSON.stringify(res)}`);
324} catch(err) {
325  console.error(`Failed to auto start apps. Code: ${err.code}, message: ${err.message}`);
326}
327```
328
329## applicationManager.addKeepAliveApps<sup>14+</sup>
330
331addKeepAliveApps(admin: Want, bundleNames: Array\<string>, accountId: number): void
332
333Adds applications to be kept alive. Currently, this feature is available only for 2-in-1 devices. If applications are disallowed to run by calling [addDisallowedRunningBundlesSync](#applicationmanageradddisallowedrunningbundlessync), they cannot be kept alive. Otherwise, a conflict occurs.
334
335**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
336
337**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
338
339
340
341**Parameters**
342
343| Name   | Type                                                   | Mandatory| Description                                                        |
344| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
345| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
346| bundleNames    | Array&lt;string&gt;                                     | Yes  | Application bundle name array, which specifies the applications to be kept alive. A maximum of five applications are supported.                                  |
347| accountId | number                                                  | Yes  | User ID, which must be greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the user ID.|
348
349**Error codes**
350
351For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
352
353| ID| Error Message                                                    |
354| -------- | ------------------------------------------------------------ |
355| 9200001  | The application is not an administrator application of the device. |
356| 9200002  | The administrator application does not have permission to manage the device. |
357| 9200010  | A conflict policy has been configured. |
358| 9201005  | Add keep alive applications failed. |
359| 201  | Permission verification failed. The application does not have the permission required to call the API. |
360| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
361
362**Example**
363
364```ts
365import { Want } from '@kit.AbilityKit';
366
367let wantTemp: Want = {
368  bundleName: 'com.example.myapplication',
369  abilityName: 'EntryAbility',
370};
371let bundleNames: Array<string> = ['com.example.myapplication'];
372
373try {
374  applicationManager.addKeepAliveApps(wantTemp, bundleNames, 100);
375  console.info('Succeeded in adding keep alive apps.');
376} catch (err) {
377  console.error(`Failed to add keep alive apps. Code is ${err.code}, message is ${err.message}`);
378}
379```
380
381## applicationManager.removeKeepAliveApps<sup>14+</sup>
382
383removeKeepAliveApps(admin: Want, bundleNames: Array\<string>, accountId: number): void
384
385Removes applications to be kept alive. Currently, this feature is available only for 2-in-1 devices.
386
387**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
388
389**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
390
391
392
393**Parameters**
394
395| Name   | Type                                                   | Mandatory| Description                                                        |
396| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
397| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
398| bundleNames    | Array&lt;string&gt;                                     | Yes  | Application bundle name array, which specifies the applications to be kept alive. A maximum of five applications are supported.                                  |
399| accountId | number                                                  | Yes  | User ID, which must be greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the user ID.|
400
401**Error codes**
402
403For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
404
405| ID| Error Message                                                    |
406| -------- | ------------------------------------------------------------ |
407| 9200001  | The application is not an administrator application of the device. |
408| 9200002  | The administrator application does not have permission to manage the device. |
409| 201  | Permission verification failed. The application does not have the permission required to call the API. |
410| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
411
412**Example**
413
414```ts
415import { Want } from '@kit.AbilityKit';
416
417let wantTemp: Want = {
418  bundleName: 'com.example.myapplication',
419  abilityName: 'EntryAbility',
420};
421let bundleNames: Array<string> = ['com.example.myapplication'];
422
423try {
424  applicationManager.removeKeepAliveApps(wantTemp, bundleNames, 100);
425  console.info('Succeeded in removing keep alive apps.');
426} catch (err) {
427  console.error(`Failed to remove keep alive apps. Code is ${err.code}, message is ${err.message}`);
428}
429```
430
431## applicationManager.getKeepAliveApps<sup>14+</sup>
432
433getKeepAliveApps(admin: Want, accountId: number): Array&lt;string>
434
435Application bundle name array, which specifies the applications to be kept alive. A maximum of five applications are supported.
436
437**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
438
439**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
440
441
442
443**Parameters**
444
445| Name   | Type                                                   | Mandatory| Description                                                        |
446| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
447| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
448| accountId | number                                                  | Yes  | User ID, which must be greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the ID.|
449
450**Return value**
451
452| Type               | Description                            |
453| ------------------- | -------------------------------- |
454| Array&lt;string&gt; | Bundle name of the application kept alive for the specified user.|
455
456**Error codes**
457
458For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
459
460| ID| Error Message                                                    |
461| -------- | ------------------------------------------------------------ |
462| 9200001  | The application is not an administrator application of the device. |
463| 9200002  | The administrator application does not have permission to manage the device. |
464| 201  | Permission verification failed. The application does not have the permission required to call the API. |
465| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
466
467**Example**
468
469```ts
470import { Want } from '@kit.AbilityKit';
471
472let wantTemp: Want = {
473  bundleName: 'com.example.myapplication',
474  abilityName: 'EntryAbility',
475};
476
477try {
478  let result: Array<string> = applicationManager.getKeepAliveApps(wantTemp, 100);
479  console.info('Succeeded in getting keep alive apps.');
480} catch (err) {
481  console.error(`Failed to get keep alive apps. Code is ${err.code}, message is ${err.message}`);
482}
483```
484
485## applicationManager.clearUpApplicationData<sup>20+</sup>
486
487clearUpApplicationData(admin: Want, bundleName: string, appIndex: number, accountId: number): void
488
489Clears all application data.
490
491**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_APPLICATION
492
493**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
494
495
496
497**Parameters**
498
499| Name    | Type                                                   | Mandatory| Description                                                        |
500| ---------  | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
501| admin      | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
502| bundleName | string                                                  | Yes  | Bundle name of the application whose data needs to be cleared.|
503| appIndex | number                                                    | Yes  | Index of the application clone. The value is an integer greater than or equal to 0.<br> You can call [getAppCloneIdentity](../apis-ability-kit/js-apis-bundleManager.md#bundlemanagergetappcloneidentity14) of @ohos.bundle.bundleManager to obtain the index.|
504| accountId | number                                                   | Yes  | User ID. The value is an integer greater than or equal to 0.<br> You can call [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9-1) of @ohos.account.osAccount to obtain the ID.|
505
506**Error codes**
507
508For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
509
510| ID| Error Message                                                    |
511| -------- | ------------------------------------------------------------ |
512| 9200001  | The application is not an administrator application of the device. |
513| 9200002  | The administrator application does not have permission to manage the device. |
514| 201  | Permission verification failed. The application does not have the permission required to call the API. |
515
516**Example**
517
518```ts
519import { Want } from '@kit.AbilityKit';
520import { applicationManager } from '@kit.MDMKit';
521
522let wantTemp: Want = {
523  bundleName: 'com.example.myapplication',
524  abilityName: 'EntryAbility',
525};
526let bundleName: string = 'com.example.exampleapplication';
527
528try {
529  applicationManager.clearUpApplicationData(wantTemp, bundleName, 0, 100);
530  console.info('Succeeded in clear up application data.');
531} catch (err) {
532  console.error(`Failed to clear up application data. Code is ${err.code}, message is ${err.message}`);
533}
534```
535
536## applicationManager.setAllowedKioskApps<sup>20+</sup>
537
538setAllowedKioskApps(admin: Want, bundleNames: Array&lt;string&gt;): void
539
540Sets applications allowed to run in kiosk mode.
541
542Kiosk mode is a system-level runtime mode that restricts a device to a single application or a set of applications. It controls the lock screen, status bar, gestures, and key features to prevent users from launching other applications or performing other operations on the device.
543
544**Required permissions**: ohos.permission.ENTERPRISE_SET_KIOSK
545
546**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
547
548**Parameters**
549
550| Name   | Type                                                   | Mandatory| Description                                                        |
551| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
552| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                              |
553| bundleNames | Array&lt;string&gt;                                   | Yes  | Bundle names of applications allowed to run in kiosk mode. If the setting is repeated, the new arrays will replace the old ones, with a maximum of 200 arrays permitted.|
554
555**Error codes**
556
557For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
558
559| ID| Error Message                                                    |
560| -------- | ------------------------------------------------------------ |
561| 9200001  | The application is not an administrator application of the device. |
562| 9200002  | The administrator application does not have permission to manage the device. |
563| 201  | Permission verification failed. The application does not have the permission required to call the API. |
564
565**Example**
566
567```ts
568import { Want } from '@kit.AbilityKit';
569import { applicationManager } from '@kit.MDMKit';
570
571let wantTemp: Want = {
572  // Replace it as required.
573  bundleName: 'com.example.edmtest',
574  abilityName: 'com.example.edmtest.EnterpriseAdminAbility',
575};
576
577try {
578  let bundleNames: Array<string> = ['com.example.test'];
579  applicationManager.setAllowedKioskApps(wantTemp, bundleNames);
580  console.info('Succeeded in setting allowed kiosk apps.');
581} catch (err) {
582  console.error(`Failed to set allowed kiosk apps. Code is ${err.code}, message is ${err.message}`);
583}
584```
585
586## applicationManager.getAllowedKioskApps<sup>20+</sup>
587
588getAllowedKioskApps(admin: Want): Array&lt;string&gt;
589
590Obtains the applications allowed to run in kiosk mode.
591
592**Required permissions**: ohos.permission.ENTERPRISE_SET_KIOSK
593
594**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
595
596
597
598**Parameters**
599
600| Name   | Type                                                   | Mandatory| Description                                                        |
601| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
602| admin     | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | EnterpriseAdminExtensionAbility.                                      |
603
604**Return value**
605
606| Type               | Description                            |
607| ------------------- | -------------------------------- |
608| Array&lt;string&gt; | Bundle names of applications allowed to run in kiosk mode.|
609
610**Error codes**
611
612For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
613
614| ID| Error Message                                                    |
615| -------- | ------------------------------------------------------------ |
616| 9200001  | The application is not an administrator application of the device. |
617| 9200002  | The administrator application does not have permission to manage the device. |
618| 201  | Permission verification failed. The application does not have the permission required to call the API. |
619
620**Example**
621
622```ts
623import { Want } from '@kit.AbilityKit';
624import { applicationManager } from '@kit.MDMKit';
625
626let wantTemp: Want = {
627  // Replace it as required.
628  bundleName: 'com.example.edmtest',
629  abilityName: 'com.example.edmtest.EnterpriseAdminAbility',
630};
631
632try {
633  let bundleNames: Array<string> = applicationManager.getAllowedKioskApps(wantTemp);
634  console.info(`Succeeded in getting allowed kiosk apps, bundleNames: ${JSON.stringify(bundleNames)}`);
635} catch (err) {
636  console.error(`Failed to get allowed kiosk apps. Code is ${err.code}, message is ${err.message}`);
637}
638```
639
640## applicationManager.isAppKioskAllowed<sup>20+</sup>
641
642isAppKioskAllowed(bundleName: string): boolean
643
644Checks whether an application is allowed to run in kiosk mode.
645
646**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
647
648
649
650**Parameters**
651
652| Name   | Type                                                   | Mandatory| Description                                                        |
653| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
654| bundleName | string                                                 | Yes  | Bundle name of the application.                                      |
655
656**Return value**
657
658| Type               | Description                            |
659| ------------------- | -------------------------------- |
660| boolean    | The value **true** means the application can run in kiosk mode; the value **false** means the opposite.|
661
662**Example**
663
664```ts
665import { applicationManager } from '@kit.MDMKit';
666
667try {
668  let isAllowed: boolean = applicationManager.isAppKioskAllowed('com.example.test');
669  console.info(`Succeeded in querying if the app is allowed kiosk, isAllowed: ${isAllowed}`);
670} catch (err) {
671  console.error(`Failed to query if the app is allowed kiosk. Code is ${err.code}, message is ${err.message}`);
672}
673```
674