• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Component Startup Rules (Stage Model)
2
3<!--Kit: Ability Kit-->
4<!--Subsystem: Ability-->
5<!--Owner: @littlejerry1-->
6<!--Designer: @ccllee1-->
7<!--Tester: @lixueqing513-->
8<!--Adviser: @huipeizi-->
9
10Component startup refers to the behavior of starting or connecting to an application component.
11
12
13- Start the [UIAbility](../reference/apis-ability-kit/js-apis-app-ability-uiAbility.md), ServiceExtensionAbility, and DataShareExtensionAbility components. For example, you can use [startAbility()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#startability), **startServiceExtensionAbility()**, [startAbilityByCall()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#startabilitybycall), and [openLink()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#openlink12).
14
15- Connect to the ServiceExtensionAbility and DataShareExtensionAbility components. For example, you can use [connectServiceExtensionAbility()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#connectserviceextensionability) and **createDataShareHelper()**.
16
17## General Component Startup Rules
18
19To deliver a better user experience, the system restricts the following behavior:
20
21
22- A background application randomly displays a dialog box, such as an ads pop-up.
23
24- Background applications wake up each other. This type of behavior occupies system resources and increases power consumption, or even causes system frozen.
25
26- A foreground application randomly redirects to another application, for example, redirecting to the payment page of another application. This type of behavior poses security risks.
27
28
29In view of this, the system formulates a set of component startup rules, as follows:
30
31- Before starting a component of another application, check whether the component can be called by others.
32
33  If the **exported** field of the component is set to **true**, the component can be called by other applications. If the field is set to **false**, the component cannot be called by other applications. If this is the case, you must also verify the permission **ohos.permission.START_INVISIBLE_ABILITY**, which is available only for system applications. For details about the **exported** fields, see [abilities](../quick-start/module-configuration-file.md#abilities).
34
35- Before starting a UIAbility component of a background application, the caller must verify the permission ohos.permission.START_ABILITIES_FROM_BACKGROUND, which is available only for system applications. For 2-in-1 devices and tablets, if an application has created a floating window in the foreground, it can start other abilities without verifying this permission after it transitions to the background.
36
37  > **NOTE**
38  >
39  > An application is considered as a foreground application only when the application process gains focus or its UIAbility component is running in the foreground.
40
41- Before using **startAbilityByCall()** to start a component running on another device, verify the permission **ohos.permission.DISTRIBUTED_DATASYNC**.
42
43The preceding component startup rules take effect since API version 9. Familiarity with these rules helps you prevent service exceptions.
44
45
46
47## Intra-Device Component Startup Rules
48
49  The rules for starting components on the same device vary in the following scenarios:
50
51- Starting the UIAbility component
52
53- Starting the ServiceExtensionAbility and DataShareExtensionAbility components
54
55- Using [startAbilityByCall](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#startabilitybycall) to start the UIAbility component
56
57![startup-rule](figures/component-startup-inner-stage.png)
58
59
60## Inter-Device Component Startup Rules
61
62  The rules for starting components on a different device vary in the following scenarios:
63
64- Starting the UIAbility component
65
66- Starting the ServiceExtensionAbility and DataShareExtensionAbility components
67
68- Using [startAbilityByCall](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#startabilitybycall) to start the UIAbility component
69
70![component-startup-rules](figures/component-startup-inter-stage.png)
71