• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AutoStartupInfo (System API)
2
3The module defines information about the application component that automatically starts upon system boot.
4
5> **NOTE**
6>
7> 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.
8>
9> The APIs of this module can be used only in the stage model.
10> The APIs provided by this module are system APIs.
11
12## Properties
13
14**System API**: This is a system API.
15
16**System capability**: SystemCapability.Ability.AbilityRuntime.Core
17
18| Name                       | Type   | Read-Only| Optional| Description                                          |
19| --------------------------- | ------- | ---- | ---- | ---------------------------------------------- |
20| bundleName                  | string  | No  | No  | Bundle name.                        |
21| moduleName                  | string  | No  | Yes  | Module name.                        |
22| abilityName                 | string  | No  | No  | Ability name.                       |
23| abilityTypeName             | string  | No  | Yes  | Ability type.                       |
24| appCloneIndex               | number  | No  | Yes  | Index of an application clone.                                |
25| userId<sup>20+</sup>        | number  | Yes  | Yes  | User ID of the application.                            |
26| setterUserId<sup>20+</sup>  | number  | Yes  | Yes  | ID of the user who sets this application to start automatically on boot.            |
27| canUserModify<sup>20+</sup> | boolean | Yes  | Yes  | Whether the developer can change the auto-start status of this application.|
28
29**Example**
30
31```ts
32import { autoStartupManager, common } from '@kit.AbilityKit';
33
34autoStartupManager.setApplicationAutoStartup({
35  bundleName: 'com.example.autostartupapp',
36  moduleName: 'entry',
37  abilityName: 'EntryAbility',
38  abilityTypeName: 'ServiceExtension'
39} as common.AutoStartupInfo, (err) => {
40  if (err) {
41    console.error(`setApplicationAutoStartup failed, err code: ${err.code}, err msg: ${err.message}.`);
42    return;
43  }
44  console.info(`setApplicationAutoStartup success.`);
45});
46```
47