• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 camera from '@ohos.multimedia.camera';
16import context from '@ohos.app.ability.common';
17import { BusinessError } from '@ohos.base';
18import Logger from '../log/HiAdLog';
19
20const TAG = 'FullScreenAdPage';
21
22@Entry
23@Component
24struct FullScreenAdPage {
25  @State message: string = 'FullScreenAdPage';
26  private context = getContext(this) as context.UIAbilityContext;
27
28  aboutToAppear() {
29    Logger.i(TAG, '%{public}s', 'aboutToAppear');
30    this.getCameraManager(this.context);
31  }
32
33  build() {
34    Row() {
35      Column() {
36        Text(this.message)
37          .fontSize(50)
38          .fontWeight(FontWeight.Bold)
39      }
40      .width('100%')
41    }
42    .height('100%')
43  }
44
45
46  private getCameraManager(context): camera.CameraManager | undefined {
47    Logger.i(TAG, '%{public}s', 'getCameraManager');
48    let cameraManager: camera.CameraManager | undefined = undefined;
49    try {
50      cameraManager = camera.getCameraManager(context);
51    } catch (error) {
52      let err = error as BusinessError;
53      console.error(`The getCameraManager call failed. error code: ${err.code}`);
54    }
55    return cameraManager;
56  }
57}