1e41f4b71Sopenharmony_ci# @ohos.app.ability.autoStartupManager (autoStartupManager) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **autoStartupManager** module provides APIs for listening for auto-startup status changes of application components and setting application components to automatically start upon system boot.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model.
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci> The APIs provided by this module are system APIs.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Modules to Import
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci```ts
16e41f4b71Sopenharmony_ciimport { autoStartupManager } from '@kit.AbilityKit';
17e41f4b71Sopenharmony_ci```
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## on
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_cion(type: 'systemAutoStartup', callback: AutoStartupCallback): void
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ciSubscribes to auto-startup status change events of an application component.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**Parameters**
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
32e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
33e41f4b71Sopenharmony_ci| type | string | Yes   | Event type. The value is fixed at **systemAutoStartup**, which can be called only by system applications.|
34e41f4b71Sopenharmony_ci| callback  | [AutoStartupCallback](js-apis-inner-application-autoStartupCallback-sys.md)   | Yes   | Callback used for subscription.     |
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci**Example**
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci```ts
39e41f4b71Sopenharmony_ciimport { autoStartupManager, common } from '@kit.AbilityKit';
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_citry {
42e41f4b71Sopenharmony_ci  autoStartupManager.on('systemAutoStartup', {
43e41f4b71Sopenharmony_ci    onAutoStartupOn(data: common.AutoStartupInfo) {
44e41f4b71Sopenharmony_ci      console.info('===> autostartupmanager onAutoStartupOn data: ' + JSON.stringify(data));
45e41f4b71Sopenharmony_ci    },
46e41f4b71Sopenharmony_ci    onAutoStartupOff(data: common.AutoStartupInfo) {
47e41f4b71Sopenharmony_ci      console.info('===> autostartupmanager onAutoStartupOff data: ' + JSON.stringify(data));
48e41f4b71Sopenharmony_ci    }
49e41f4b71Sopenharmony_ci  });
50e41f4b71Sopenharmony_ci} catch (err) {
51e41f4b71Sopenharmony_ci  console.info('===> autostartupmanager on throw err: ' + JSON.stringify(err));
52e41f4b71Sopenharmony_ci}
53e41f4b71Sopenharmony_ci```
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci## off
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_cioff(type: 'systemAutoStartup', callback?: AutoStartupCallback): void
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ciUnsubscribes from auto-startup status change events of an application component.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**Parameters**
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
68e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
69e41f4b71Sopenharmony_ci| type | string              | Yes   | Event type. The value is fixed at **systemAutoStartup**, which can be called only by system applications.|
70e41f4b71Sopenharmony_ci| callback | [AutoStartupCallback](js-apis-inner-application-autoStartupCallback-sys.md)   | No| Callback used for unsubscription.|
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci**Example**
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci```ts
75e41f4b71Sopenharmony_ciimport { autoStartupManager, common } from '@kit.AbilityKit';
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_citry {
78e41f4b71Sopenharmony_ci  autoStartupManager.off('systemAutoStartup', {
79e41f4b71Sopenharmony_ci    onAutoStartupOn(data: common.AutoStartupInfo) {
80e41f4b71Sopenharmony_ci      console.info('===> autostartupmanager onAutoStartupOn data: ' + JSON.stringify(data));
81e41f4b71Sopenharmony_ci    },
82e41f4b71Sopenharmony_ci    onAutoStartupOff(data: common.AutoStartupInfo) {
83e41f4b71Sopenharmony_ci      console.info('===> autostartupmanager onAutoStartupOff data: ' + JSON.stringify(data));
84e41f4b71Sopenharmony_ci    }
85e41f4b71Sopenharmony_ci  });
86e41f4b71Sopenharmony_ci} catch (err) {
87e41f4b71Sopenharmony_ci  console.info('===> autostartupmanager off throw err: ' + JSON.stringify(err));
88e41f4b71Sopenharmony_ci}
89e41f4b71Sopenharmony_ci```
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci## setApplicationAutoStartup
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_cisetApplicationAutoStartup(info: AutoStartupInfo, callback: AsyncCallback\<void\>): void
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ciSets an application component to automatically start upon system boot. This API uses an asynchronous callback to return the result.
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**Parameters**
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
104e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
105e41f4b71Sopenharmony_ci| info | [AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md) | Yes   | Information about the target application component.|
106e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes| Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci**Error codes**
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci| ID| Error Message                                    |
111e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
112e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability.           |
113e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM.        |
114e41f4b71Sopenharmony_ci| 16000050 | Internal error.                              |
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ciFor details about the error codes, see [Ability Error Codes](errorcode-ability.md).
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**Example**
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci```ts
121e41f4b71Sopenharmony_ciimport { autoStartupManager } from '@kit.AbilityKit';
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_citry {
124e41f4b71Sopenharmony_ci  autoStartupManager.setApplicationAutoStartup({
125e41f4b71Sopenharmony_ci    bundleName: 'com.example.autostartupapp',
126e41f4b71Sopenharmony_ci    abilityName: 'EntryAbility'
127e41f4b71Sopenharmony_ci  }, (err, data) => {
128e41f4b71Sopenharmony_ci    console.info('====> setApplicationAutoStartup: ' + JSON.stringify(err) + ' data: ' + JSON.stringify(data));
129e41f4b71Sopenharmony_ci  });
130e41f4b71Sopenharmony_ci} catch (err) {
131e41f4b71Sopenharmony_ci  console.info('====> setApplicationAutoStartup throw err: ' + JSON.stringify(err));
132e41f4b71Sopenharmony_ci}
133e41f4b71Sopenharmony_ci```
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci## setApplicationAutoStartup
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_cisetApplicationAutoStartup(info: AutoStartupInfo): Promise\<void\>
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciSets an application component to automatically start upon system boot. This API uses a promise to return the result.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**Parameters**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| Name| Type           | Mandatory| Description                        |
148e41f4b71Sopenharmony_ci| ------ | --------------- | ---- | ---------------------------- |
149e41f4b71Sopenharmony_ci| info   | [AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md) | Yes  | Information about the target application component.|
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**Return value**
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci| Type         | Description                                                        |
154e41f4b71Sopenharmony_ci| ------------- | ------------------------------------------------------------ |
155e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value.|
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci**Error codes**
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci| ID| Error Message                                    |
160e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
161e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability.           |
162e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM.        |
163e41f4b71Sopenharmony_ci| 16000050 | Internal error.                              |
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ciFor details about the error codes, see [Ability Error Codes](errorcode-ability.md).
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci**Example**
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci```ts
170e41f4b71Sopenharmony_ciimport { autoStartupManager } from '@kit.AbilityKit';
171e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_citry {
174e41f4b71Sopenharmony_ci  autoStartupManager.setApplicationAutoStartup({
175e41f4b71Sopenharmony_ci    bundleName: 'com.example.autostartupapp',
176e41f4b71Sopenharmony_ci    abilityName: 'EntryAbility'
177e41f4b71Sopenharmony_ci  }).then((data: void) => {
178e41f4b71Sopenharmony_ci    console.info('====> setApplicationAutoStartup data: ' + JSON.stringify(data));
179e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
180e41f4b71Sopenharmony_ci    console.info('====> setApplicationAutoStartup err: ' + JSON.stringify(err));
181e41f4b71Sopenharmony_ci  });
182e41f4b71Sopenharmony_ci} catch (err) {
183e41f4b71Sopenharmony_ci  console.info('====> setApplicationAutoStartup throw err: ' + JSON.stringify(err));
184e41f4b71Sopenharmony_ci}
185e41f4b71Sopenharmony_ci```
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci## cancelApplicationAutoStartup
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_cicancelApplicationAutoStartup(info: AutoStartupInfo, callback: AsyncCallback\<void\>): void
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ciCancels the auto-startup setting for an application component. This API uses an asynchronous callback to return the result.
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**Parameters**
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
200e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
201e41f4b71Sopenharmony_ci| info | [AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md)   | Yes| Information about the target application component.|
202e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes   | Callback used to return the result. If the cancellation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**Error codes**
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci| ID| Error Message                                    |
207e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
208e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability.           |
209e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM.        |
210e41f4b71Sopenharmony_ci| 16000050 | Internal error.                              |
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ciFor details about the error codes, see [Ability Error Codes](errorcode-ability.md).
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**Example**
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci```ts
217e41f4b71Sopenharmony_ciimport { autoStartupManager } from '@kit.AbilityKit';
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_citry {
220e41f4b71Sopenharmony_ci  autoStartupManager.cancelApplicationAutoStartup({
221e41f4b71Sopenharmony_ci    bundleName: 'com.example.autostartupapp',
222e41f4b71Sopenharmony_ci    abilityName: 'EntryAbility'
223e41f4b71Sopenharmony_ci  }, (err, data) => {
224e41f4b71Sopenharmony_ci    console.info('====> cancelApplicationAutoStartup err: ' + JSON.stringify(err) + ' data: ' + JSON.stringify(data));
225e41f4b71Sopenharmony_ci  });
226e41f4b71Sopenharmony_ci} catch (err) {
227e41f4b71Sopenharmony_ci  console.info('====> cancelApplicationAutoStartup throw err: ' + JSON.stringify(err));
228e41f4b71Sopenharmony_ci}
229e41f4b71Sopenharmony_ci```
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci## cancelApplicationAutoStartup
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_cicancelApplicationAutoStartup(info: AutoStartupInfo): Promise\<void\>
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ciCancels the auto-startup setting for an application component. This API uses a promise to return the result.
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci**Parameters**
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
244e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
245e41f4b71Sopenharmony_ci| info | [AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md)   | Yes| Information about the target application component.|
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci**Return value**
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci| Type         | Description                                                        |
250e41f4b71Sopenharmony_ci| ------------- | ------------------------------------------------------------ |
251e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value.|
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci**Error codes**
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci| ID| Error Message                                    |
256e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
257e41f4b71Sopenharmony_ci| 16000004 | Failed to start the invisible ability.           |
258e41f4b71Sopenharmony_ci| 16000013 | The application is controlled by EDM.        |
259e41f4b71Sopenharmony_ci| 16000050 | Internal error.                              |
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ciFor details about the error codes, see [Ability Error Codes](errorcode-ability.md).
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci**Example**
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci```ts
266e41f4b71Sopenharmony_ciimport { autoStartupManager } from '@kit.AbilityKit';
267e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_citry {
270e41f4b71Sopenharmony_ci  autoStartupManager.cancelApplicationAutoStartup({
271e41f4b71Sopenharmony_ci    bundleName: 'com.example.autostartupapp',
272e41f4b71Sopenharmony_ci    abilityName: 'EntryAbility'
273e41f4b71Sopenharmony_ci  }).then((data: void) => {
274e41f4b71Sopenharmony_ci    console.info('====> cancelApplicationAutoStartup data: ' + JSON.stringify(data));
275e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
276e41f4b71Sopenharmony_ci    console.info('====> cancelApplicationAutoStartup err: ' + JSON.stringify(err));
277e41f4b71Sopenharmony_ci  });
278e41f4b71Sopenharmony_ci} catch (err) {
279e41f4b71Sopenharmony_ci  console.info('====> cancelApplicationAutoStartup throw err: ' + JSON.stringify(err));
280e41f4b71Sopenharmony_ci}
281e41f4b71Sopenharmony_ci```
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ci## queryAllAutoStartupApplications
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ciqueryAllAutoStartupApplications(callback: AsyncCallback\<Array\<AutoStartupInfo\>\>): void
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ciObtains information about all auto-startup application components. This API uses an asynchronous callback to return the result.
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci**Parameters**
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory  | Description            |
296e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------------- |
297e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<Array\<[AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md)\>\> | Yes   | Callback used to return the result. If the information is obtained, **err** is **undefined** and **data** is **Array\<[AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md)\>**; otherwise, **err** is an error object.     |
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**Error codes**
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci| ID| Error Message|
302e41f4b71Sopenharmony_ci| ------- | -------- |
303e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ciFor details about the error codes, see [Ability Error Codes](errorcode-ability.md).
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci**Example**
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci```ts
310e41f4b71Sopenharmony_ciimport { autoStartupManager } from '@kit.AbilityKit';
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_citry {
313e41f4b71Sopenharmony_ci  autoStartupManager.queryAllAutoStartupApplications((err, data) => {
314e41f4b71Sopenharmony_ci    console.info('====> queryAllAutoStartupApplications err: ' + JSON.stringify(err) + ' data: ' + JSON.stringify(data));
315e41f4b71Sopenharmony_ci  });
316e41f4b71Sopenharmony_ci} catch (err) {
317e41f4b71Sopenharmony_ci  console.info('====> queryAllAutoStartupApplications throw err: ' + JSON.stringify(err));
318e41f4b71Sopenharmony_ci}
319e41f4b71Sopenharmony_ci```
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci## queryAllAutoStartupApplications
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci queryAllAutoStartupApplications(): Promise\<Array\<AutoStartupInfo\>\>
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ciObtains information about all auto-startup application components. This API uses a promise to return the result.
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_APP_BOOT
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci**Return value**
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
334e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
335e41f4b71Sopenharmony_ci| Promise\<Array\<[AutoStartupInfo](js-apis-inner-application-autoStartupInfo-sys.md)\>\> | Promise used to return the information obtained.|
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**Error codes**
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci| ID| Error Message|
340e41f4b71Sopenharmony_ci| ------- | -------- |
341e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ciFor details about the error codes, see [Ability Error Codes](errorcode-ability.md).
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**Example**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci```ts
348e41f4b71Sopenharmony_ciimport { autoStartupManager, common } from '@kit.AbilityKit';
349e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_citry {
352e41f4b71Sopenharmony_ci  autoStartupManager.queryAllAutoStartupApplications().then((autoStartupInfo: common.AutoStartupInfo[]) => {
353e41f4b71Sopenharmony_ci    console.info('====> queryAllAutoStartupApplications data: ' + JSON.stringify(autoStartupInfo));
354e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
355e41f4b71Sopenharmony_ci    console.info('====> queryAllAutoStartupApplications err: ' + JSON.stringify(err));
356e41f4b71Sopenharmony_ci  });
357e41f4b71Sopenharmony_ci} catch (err) {
358e41f4b71Sopenharmony_ci  console.info('====> queryAllAutoStartupApplications throw err: ' + JSON.stringify(err));
359e41f4b71Sopenharmony_ci}
360e41f4b71Sopenharmony_ci```
361