• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# HalfScreenLaunchComponent
2
3**HalfScreenLaunchComponent** is a component designed for launching atomic services in half screen. If the invoked application (the one being launched) grants the invoker the authorization to run the atomic service in an embedded manner, the invoker can operate the atomic service in half-screen embedded mode. If authorization is not provided, the invoker will launch the atomic service in a pop-up manner.
4
5> **NOTE**
6>
7> This component is supported since API version 18. Updates will be marked with a superscript to indicate their earliest API version.
8>
9> To implement an embeddable atomic service, make sure it inherits from [EmbeddableUIAbility](../../apis-ability-kit/js-apis-app-ability-embeddableUIAbility.md). This ensures that it functions properly.
10
11## Modules to Import
12
13```
14import { HalfScreenLaunchComponent } from '@kit.ArkUI';
15```
16
17## Child Components
18
19Not supported
20
21## Attributes
22The [universal attributes](ts-component-general-attributes.md) are not supported.
23
24## HalfScreenLaunchComponent
25
26HalfScreenLaunchComponent({
27&emsp;content: Callback\<void>,
28&emsp;appId: string,
29&emsp;options?: AtomicServiceOptions,
30&emsp;onError?: ErrorCallback,
31&emsp;onTerminated?: Callback&lt;TerminationInfo&gt;
32  })
33
34**Decorator**: \@Component
35
36**System capability**: SystemCapability.ArkUI.ArkUI.Full
37
38**Parameters**
39
40| Name| Type| Mandatory| Decorator| Description|
41| -------- | -------- | -------- | -------- | -------- |
42| content | Callback\<void> | Yes| \@BuilderParam | Content displayed in the component.<br>**Atomic service API**: This API can be used in atomic services since API version 18.|
43| appId | string | Yes| - | Application ID for the atomic service.<br>**Atomic service API**: This API can be used in atomic services since API version 18.|
44| options | [AtomicServiceOptions](../../apis-ability-kit/js-apis-app-ability-atomicServiceOptions.md) | No| - | Parameters for starting the atomic service. The default value is empty.<br>**Atomic service API**: This API can be used in atomic services since API version 18.|
45| onError |[ErrorCallback](../../apis-basic-services-kit/js-apis-base.md#errorcallback) | No| - | Invoked when an error occurs during the running of the atomic service.<br>**Atomic service API**: This API can be used in atomic services since API version 18.|
46| onTerminated | [Callback](../../apis-basic-services-kit/js-apis-base.md#callback)\<TerminationInfo> | No| - |  Callback used to return the result of the atomic service. The input parameter is of type **TerminationInfo**.<br>**Atomic service API**: This API can be used in atomic services since API version 18.|
47| onReceive<sup>20+<sup> | [Callback](../../apis-basic-services-kit/js-apis-base.md#callback)\<Record<string, Object>> | No| - | Callback triggered when the embedded atomic service is launched through [Window](../../../windowmanager/application-window-stage.md) API calls.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
48
49## Example
50
51This example demonstrates how to start a top-up service in embedded mode.
52
53```ts
54import { HalfScreenLaunchComponent } from '@kit.ArkUI';
55
56@Entry
57@Component
58struct Index {
59  appId: string = "5765880207853275489"; // Application ID of the atomic service.
60
61  build() {
62    Column() {
63      HalfScreenLaunchComponent({
64        appId: this.appId,
65        options: {},
66        onTerminated:  (info:TerminationInfo)=> {
67          console.info('onTerminated info = '+ info.want);
68        },
69        onError: (err) => {
70          console.error(" onError code: " + err.code + ", message: ", err.message);
71        },
72        onReceive: (data) => {
73          console.info("onReceive, data: " + data['ohos.atomicService.window']);
74        }
75      }) {
76        Column() {
77          Image($r('app.media.app_icon'))
78          Text('Start top-up')
79        }.width("80vp").height("80vp").margin({bottom:30})
80      } // Content is passed as a trailing closure.
81    }
82  }
83
84}
85```
86