• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 # AutoStartupInfo
2
3The **AutoStartupInfo** 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
11## Attributes
12
13**System capability**: SystemCapability.Ability.AbilityRuntime.Core
14
15| Name                     | Type  | Mandatory | Description      |
16| ------------------------- | ------ | ---- | --------- |
17| bundleName   | string | Yes | Bundle name.|
18| moduleName | string | No  | Module name.|
19| abilityName | string | Yes | Ability name.|
20| abilityTypeName | string | No| Ability type.|
21
22**Example**
23
24```ts
25import UIAbility from '@ohos.app.ability.UIAbility';
26
27export default class MyAbility extends UIAbility {
28  onBackground() {
29    let applicationContext = this.context.getApplicationContext();
30    try {
31      applicationContext.setAutoStartup({
32        bundleName: 'com.example.autostartupapp',
33        moduleName: 'entry',
34        abilityName: 'EntryAbility',
35        abilityTypeName: 'ServiceExtension'
36      }, (err, data) => {
37        console.info('====> err: ' + JSON.stringify(err) + ' data: ' + JSON.stringify(data));
38      });
39    } catch (err) {
40      console.info('===> autostartupmanager setAutoStartup throw err: ' + JSON.stringify(err));
41    }
42  }
43}
44```
45