• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Component Startup Rules (Stage Model)
2
3
4Component startup refers to the behavior of starting or connecting to an application component.
5
6
7- Start the UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility components. For example, you can use **startAbility()**, **startServiceExtensionAbility()**, and **startAbilityByCall()**.
8
9- Connect to the ServiceExtensionAbility and DataShareExtensionAbility components. For example, you can use **connectServiceExtensionAbility()** and **createDataShareHelper()**.
10
11
12To deliver a better user experience, OpenHarmony restricts the following behavior:
13
14
15- A background application randomly displays a dialog box, such as an ads pop-up.
16
17- Background applications wake up each other. This type of behavior occupies system resources and increases power consumption, or even causes system frozen.
18
19- 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.
20
21
22In view of this, OpenHarmony formulates a set of component startup rules, as follows:
23
24
25- **Before starting a component of another application, verify the visible field of the target component.**
26  - If the **visible** field of the target component is **false**, verify the **ohos.permission.START_INVISIBLE_ABILITY** permission.
27  - For details, see [Component Visible Configuration](../quick-start/module-configuration-file.md#abilities).
28
29- **Before starting a component of a background application, verify the BACKGROUND permission.**
30  - An application is considered as a foreground application only when the application process gains focus or its UIAbility component is running in the foreground.
31  - Verify the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
32
33- **When the startAbilityByCall() method is used, verify the call permission.** For details, see [Using Call to Implement UIAbility Interaction](uiability-intra-device-interaction.md#using-call-to-implement-uiability-interaction) and [Using Cross-Device Call](hop-multi-device-collaboration.md#using-cross-device-call).
34  - Verify the **ohos.permission.ABILITY_BACKGROUND_COMMUNICATION** permission.
35
36
37> **NOTE**
38>
39> - Component startup control has been implemented since OpenHarmony v3.2 Release.
40>
41> - The new component startup rules are more strict than the original ones. You must be familiar with the new startup rules to prevent service exceptions.
42
43
44## Intra-Device Component Startup Rules
45
46  The rules for starting components on the same device vary in the following scenarios:
47
48- Starting or connecting to the UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility components
49
50- Using **startAbilityByCall()** to start the UIAbility component
51
52![startup-rule](figures/component-startup-inner-stage.png)
53
54
55## Inter-Device Component Startup Rules
56
57  The rules for starting components on a different device vary in the following scenarios:
58
59- Starting or connecting to the UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility components
60
61- Using **startAbilityByCall()** to start the UIAbility component
62
63![component-startup-rules](figures/component-startup-inter-stage.png)
64
65