• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { Want } from '@kit.AbilityKit';
16import { BusinessError, commonEventManager } from '@kit.BasicServicesKit';
17import { hilog } from '@kit.PerformanceAnalysisKit';
18
19@Entry
20@Component
21struct EtyB {
22  @State message: string = 'Hello World';
23  private want: Want = {
24    bundleName: 'com.example.assistappa',
25    abilityName: 'EmbeddedUIExtAbilityInstance',
26    parameters: {
27
28    }
29  }
30
31  build() {
32    Row() {
33      Column() {
34        Text(this.message).fontSize(30)
35        EmbeddedComponent(this.want, EmbeddedType.EMBEDDED_UI_EXTENSION)
36          .width('100%')
37          .height('90%')
38          .onTerminated((info: TerminationInfo) => {
39            this.message = 'Terminarion: code = ' + info.code + ', want = ' + JSON.stringify(info.want);
40            console.log('shuzi',JSON.stringify(EmbeddedType.EMBEDDED_UI_EXTENSION))
41          })
42          .onError((error: BusinessError) => {
43            this.message = 'Error: code = ' + error.code;
44            console.log('instance',JSON.stringify(error))
45            let commonEventPublishData: commonEventManager.CommonEventPublishData ={
46              parameters:{
47                data: error.code
48              }
49            }
50            commonEventManager.publish('ExtensionInstance', commonEventPublishData, async (error) =>{
51              hilog.info(0x0000, 'testTag1', '%{public}s', `Embeddedextension publish: ${JSON.stringify(error)}`);
52            })
53          })
54        EmbeddedComponent(this.want, EmbeddedType.EMBEDDED_UI_EXTENSION)
55          .width('100%')
56          .height('90%')
57          .onTerminated((info: TerminationInfo) => {
58            this.message = 'Terminarion: code = ' + info.code + ', want = ' + JSON.stringify(info.want);
59            console.log('shuzi',JSON.stringify(EmbeddedType.EMBEDDED_UI_EXTENSION))
60          })
61          .onError((error: BusinessError) => {
62            this.message = 'Error: code = ' + error.code;
63            console.log('instance',JSON.stringify(error))
64          })
65      }
66      .width('100%')
67    }
68    .height('100%')
69  }
70}