diff --git a/README.en.md b/README.en.md index 2b7edf4ad730cf605e2692b19939197fdb629bce..10a6c6c253d564ba757edbf4c59130f37ef41878 100644 --- a/README.en.md +++ b/README.en.md @@ -22,8 +22,7 @@ This sample shows how to select and save documents, select and view photos in th ``` ├──entry/src/main/ets/ │ ├──common -│ │ ├──CommonConstants.ets // Constants -│ │ └──Logger.ets // Logging utility +│ │ └──CommonConstants.ets // Constants │ ├──component │ │ ├──EditFile.ets // Page for viewing and editing a document │ │ ├──PickerComponent.ets // Home page @@ -33,6 +32,7 @@ This sample shows how to select and save documents, select and view photos in th │ ├──utils │ │ ├──BreakpointSystem.ets // Breakpoint utils │ │ ├──StringUtils.ets // String utils +│ │ ├──Logger.ets // Log utils │ │ └──WindowUtil.ets // Window utils │ └──PickerController.ets // Export utils └──entry/src/main/resources // Static resources of the app diff --git a/README.md b/README.md index dc8bdb8b715bc3b14d0b94d5a19b9abb376dd39b..2d3171b135a4f24ae0f1677a103481de566bcc2e 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,7 @@ ``` ├──entry/src/main/ets/ │ ├──common -│ │ ├──CommonConstants.ets // 常量 -│ │ └──Logger.ets // 日志工具 +│ │ └──CommonConstants.ets // 常量 │ ├──component │ │ ├──EditFile.ets // 查看并编辑文档界面 │ │ ├──PickerComponent.ets // 首页 @@ -35,6 +34,7 @@ │ ├──utils │ │ ├──BreakpointSystem.ets // 断点工具 │ │ ├──StringUtils.ets // 字符串工具 +│ │ ├──Logger.ets // 日志工具类 │ │ └──WindowUtil.ets // 窗口工具 │ └──PickerController.ets // 导出工具类 └──entry/src/main/resources // 应用静态资源目录 diff --git a/build-profile.json5 b/build-profile.json5 index d98a671ca31648e58f88c1ace53e20873cec5f78..d134a89d7e7ec1b34c7c87a33ae721feea8eee8b 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,7 +5,8 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.5(17)", + "targetSdkVersion": "5.0.5(17)", "runtimeOS": "HarmonyOS" } ] diff --git a/pickerlibrary/Index.ets b/pickerlibrary/Index.ets index fc5106f34a33012b45a0513e5b64a6093b61f792..30c5696f8317d3158771e76d84f0adebcc13551c 100644 --- a/pickerlibrary/Index.ets +++ b/pickerlibrary/Index.ets @@ -1,2 +1,3 @@ export { PickerComponent } from './src/main/ets/component/PickerComponent'; -export { PickerController } from './src/main/ets/PickerController'; \ No newline at end of file +export { PickerController } from './src/main/ets/PickerController'; +export { default as Logger } from './src/main/ets/utils/Logger'; \ No newline at end of file diff --git a/pickerlibrary/README.md b/pickerlibrary/README.md index 916a57e8ad2ad505752b1a79d9a154d872a60fb7..48034dafd7c24cd8dda35ce94c0303f261049713 100644 --- a/pickerlibrary/README.md +++ b/pickerlibrary/README.md @@ -41,7 +41,7 @@ import { PickerController } from '@ohos_samples/pickerlibrary'; onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { - hilog.error(0x0000, 'testTag', `Failed to load the content, err code: ${err.code}, message: ${err.message}`); + Logger.error(TAG, `Failed to load the content, err code: ${err.code}, message: ${err.message}`); return; } PickerController.initWindowConfig(windowStage); diff --git a/pickerlibrary/src/main/ets/component/EditFile.ets b/pickerlibrary/src/main/ets/component/EditFile.ets index c6f95f1a6543fafd38d02754e6d3b16ab7f8a7c2..cd3c976f78afed1753867b39d2a7e5bcbd6a7f68 100644 --- a/pickerlibrary/src/main/ets/component/EditFile.ets +++ b/pickerlibrary/src/main/ets/component/EditFile.ets @@ -18,8 +18,8 @@ import { fileIo, picker } from '@kit.CoreFileKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/CommonConstants'; import { FileParam } from './PickerComponent'; -import Logger from '../common/Logger'; import MediaFileUri from '../media/MediaFileUri'; +import Logger from '../utils/Logger'; const TAG = 'EditFile: '; const OPACITY_VALUE = 0.6; @@ -107,38 +107,46 @@ struct EditFile { writeFileContent2CurrentFile(): void { let isWriteSuccess: boolean = true; - if (this.loadFlag) { - let file = fileIo.openSync(this.loadUri, - fileIo.OpenMode.CREATE | fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.TRUNC); - Logger.info(TAG, 'save onClick file.fd succeed. '); - fileIo.write(file.fd, this.myFileContent).then(() => { - Logger.info(TAG, 'write data to file succeed.'); - this.myFileSize = fileIo.statSync(file.fd).size; - Logger.info(TAG, 'save onClick fileSize succeed.'); - }).catch((err: BusinessError) => { - Logger.error(TAG, `write data to file failed, ErrorCode: ${err.code}, Message: ${err.message}`); - }).finally(() => { - fileIo.closeSync(file); - }) - } else { - let file = fileIo.openSync(this.myUri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.TRUNC); - fileIo.write(file.fd, this.myFileContent).then(() => { - this.myFileSize = fileIo.statSync(file.fd).size; - Logger.info(TAG, 'write data to file succeed.'); - }).catch((err: BusinessError) => { - isWriteSuccess = false; - Logger.error(TAG, `save data to file failed ErrorCode: ${err.code}, Message: ${err.message}`); - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.show_toast_message'), - duration: CommonConstants.WRITE_SUCCESS_DURATION + try { + if (this.loadFlag) { + let file = fileIo.openSync(this.loadUri, + fileIo.OpenMode.CREATE | fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.TRUNC); + Logger.info(TAG, 'save onClick file.fd succeed. '); + fileIo.write(file.fd, this.myFileContent).then(() => { + Logger.info(TAG, 'write data to file succeed.'); + this.myFileSize = fileIo.statSync(file.fd).size; + Logger.info(TAG, 'save onClick fileSize succeed.'); + }).catch((err: BusinessError) => { + Logger.error(TAG, `write data to file failed, ErrorCode: ${err.code}, Message: ${err.message}`); + }).finally(() => { + fileIo.closeSync(file); }) - }).finally(() => { - fileIo.closeSync(file); - }) + } else { + let file = fileIo.openSync(this.myUri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.TRUNC); + fileIo.write(file.fd, this.myFileContent).then(() => { + this.myFileSize = fileIo.statSync(file.fd).size; + Logger.info(TAG, 'write data to file succeed.'); + }).catch((err: BusinessError) => { + isWriteSuccess = false; + Logger.error(TAG, `save data to file failed ErrorCode: ${err.code}, Message: ${err.message}`); + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.show_toast_message'), + duration: CommonConstants.WRITE_SUCCESS_DURATION + }) + }).finally(() => { + fileIo.closeSync(file); + }) + } + } catch (err) { + Logger.error(TAG, `openSync failed, ErrorCode: ${err.code}, Message: ${err.message}`); } if (isWriteSuccess) { this.editable = false; - this.getUIContext().getPromptAction().showToast({ message: $r('app.string.saved') }); + try { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.saved') }); + } catch (err) { + Logger.error(TAG, `showToast failed, ErrorCode: ${err.code}, Message: ${err.message}`); + } } } diff --git a/pickerlibrary/src/main/ets/component/PickerComponent.ets b/pickerlibrary/src/main/ets/component/PickerComponent.ets index 0ffdfe7d4f7bbf1301688d4ec929274afbffb6c8..5b2efcb930e0d4453635e267824ebec6ae9bf881 100644 --- a/pickerlibrary/src/main/ets/component/PickerComponent.ets +++ b/pickerlibrary/src/main/ets/component/PickerComponent.ets @@ -18,8 +18,8 @@ import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { picker } from '@kit.CoreFileKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/CommonConstants'; -import Logger from '../common/Logger'; import MediaFileUri from '../media/MediaFileUri'; +import Logger from '../utils/Logger'; const MAX_SELECT_NUM = 4; // Select the maximum number of media files. const TAG = 'pickerIndex'; @@ -211,7 +211,7 @@ export struct PickerComponent { } .titleMode(NavigationTitleMode.Full) .mode(NavigationMode.Stack) - .title(this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.last_open').id)) + .title(this.getTitle()) } .padding({ right: new BreakpointType({ @@ -230,4 +230,13 @@ export struct PickerComponent { .backgroundColor($r('sys.color.background_secondary')) } } + + getTitle(): string { + try { + this.getUIContext().getHostContext()?.resourceManager.getStringSync($r('app.string.last_open').id); + } catch (err) { + Logger.error(TAG, `getStringSync failed, ErrorCode: ${err.code}, Message: ${err.message}`); + } + return ''; + } } \ No newline at end of file diff --git a/pickerlibrary/src/main/ets/component/ViewMedia.ets b/pickerlibrary/src/main/ets/component/ViewMedia.ets index 36072dfb4cb8a0a385af53707d11afe80b2013f1..26735e61dae0d522068c3d70f5977b180e9da3b8 100644 --- a/pickerlibrary/src/main/ets/component/ViewMedia.ets +++ b/pickerlibrary/src/main/ets/component/ViewMedia.ets @@ -16,9 +16,9 @@ import { fileIo } from '@kit.CoreFileKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/CommonConstants'; -import Logger from '../common/Logger'; import MediaFileUri from '../media/MediaFileUri'; import { UrisParam } from './PickerComponent'; +import Logger from '../utils/Logger'; const TAG = 'ViewMedia'; diff --git a/pickerlibrary/src/main/ets/media/MediaFileUri.ets b/pickerlibrary/src/main/ets/media/MediaFileUri.ets index 387c6f6cbbf36b20c9df84bc3a5be12c1c92fc48..e7c323fafd1957498bb7577662bbd11d5318a99c 100644 --- a/pickerlibrary/src/main/ets/media/MediaFileUri.ets +++ b/pickerlibrary/src/main/ets/media/MediaFileUri.ets @@ -16,7 +16,7 @@ import { fileIo } from '@kit.CoreFileKit'; import { bufferToString } from '../utils/StringUtils'; import { CommonConstants } from '../common/CommonConstants'; -import Logger from '../common/Logger'; +import Logger from '../utils/Logger'; const TAG = 'MediaFileUri'; // File read/write buffer size @@ -29,36 +29,47 @@ export default class MediaFileUri { readFileContent(uri: string): string { let content = ''; - let file = fileIo.openSync(uri, fileIo.OpenMode.READ_ONLY); try { + let file = fileIo.openSync(uri, fileIo.OpenMode.READ_ONLY); let buffer = new ArrayBuffer(BUFFER_SIZE); fileIo.readSync(file.fd, buffer, { offset: 0 }); content = bufferToString(buffer); + fileIo.closeSync(file); } catch (err) { Logger.error(TAG, 'openReadSync: open file failed.'); } - fileIo.closeSync(file); return content; } myGetFileSize(uri: string, mode: number): number { - let file = fileIo.openSync(uri, mode); - let stat = fileIo.statSync(file.fd); - fileIo.close(file) - Logger.info(TAG, 'get file info succeed.'); - return stat.size; + try { + let file = fileIo.openSync(uri, mode); + let stat = fileIo.statSync(file.fd); + fileIo.closeSync(file); + Logger.info(TAG, 'get file info succeed.'); + return stat.size; + } catch (err) { + Logger.error(TAG, 'openReadSync: open file failed.'); + } + return 0; } writeFileContent(uri: string, content: string): void { Logger.info(TAG, 'writeFileContent begin'); - let file = fileIo.openSync(uri, fileIo.OpenMode.READ_WRITE); - fileIo.write(file.fd, content).then(() => { - Logger.info(TAG, 'writeFileContent write data to file succeed.'); - }).finally(() => { - fileIo.closeSync(file); - }) + try { + let file = fileIo.openSync(uri, fileIo.OpenMode.READ_WRITE); + fileIo.write(file.fd, content).then(() => { + Logger.info(TAG, 'writeFileContent write data to file succeed.'); + }).catch(()=>{ + Logger.error(TAG, 'write file failed.'); + }).finally(() => { + fileIo.closeSync(file); + }) + } catch (err) { + Logger.error(TAG, 'openSync file failed.'); + } } async getAllFiles(): Promise { diff --git a/pickerlibrary/src/main/ets/utils/BreakpointSystem.ets b/pickerlibrary/src/main/ets/utils/BreakpointSystem.ets index 3f0b49da401cd5997f1a4c20010b034322603f8b..44f5e4aa95d4aa35e6ebb01e68b4118decb1b1a9 100644 --- a/pickerlibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/pickerlibrary/src/main/ets/utils/BreakpointSystem.ets @@ -15,8 +15,8 @@ import type { BusinessError } from '@kit.BasicServicesKit'; import { display, window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstants } from '../common/CommonConstants'; +import Logger from './Logger'; const TAG: string = '[BreakpointSystem]'; @@ -114,7 +114,7 @@ export class BreakpointSystem { this.updateCurrentBreakpoint(widthBp); } catch (error) { const err: BusinessError = error as BusinessError; - hilog.error(0x0000, TAG, `UpdateBreakpoint fail, error code: ${err.code}, message: ${err.message}`); + Logger.error(TAG, `UpdateBreakpoint fail, error code: ${err.code}, message: ${err.message}`); } } } \ No newline at end of file diff --git a/pickerlibrary/src/main/ets/common/Logger.ets b/pickerlibrary/src/main/ets/utils/Logger.ets similarity index 65% rename from pickerlibrary/src/main/ets/common/Logger.ets rename to pickerlibrary/src/main/ets/utils/Logger.ets index 8cbb4628fe5d0d9422ea276b825549fd492d116c..13cc655f49e88cb18a9d03f21c33248c4bbf7921 100644 --- a/pickerlibrary/src/main/ets/common/Logger.ets +++ b/pickerlibrary/src/main/ets/utils/Logger.ets @@ -1,56 +1,45 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; - -/** - * Common log for all features. - */ -export class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - constructor(prefix: string) { - this.prefix = prefix; - this.domain = 0x0000; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } - - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); - } - - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); - } - - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); - } - - fatal(...args: string[]): void { - hilog.fatal(this.domain, this.prefix, this.format, args); - } - - isLoggable(level: number): void { - hilog.isLoggable(this.domain, this.prefix, level); - } -} - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + public constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0x0000; + } + + public debug(...args: Object[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + public info(...args: Object[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + public warn(...args: Object[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + public error(...args: Object[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + export default new Logger('[Picker]'); \ No newline at end of file diff --git a/pickerlibrary/src/main/ets/utils/WindowUtil.ets b/pickerlibrary/src/main/ets/utils/WindowUtil.ets index 97cfbe0e76fed629edf2d223ca8939a2c334bea6..c54a9a47661f223601a9d6b1263f1db9a3a65c42 100644 --- a/pickerlibrary/src/main/ets/utils/WindowUtil.ets +++ b/pickerlibrary/src/main/ets/utils/WindowUtil.ets @@ -14,10 +14,10 @@ */ import type { BusinessError } from '@kit.BasicServicesKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; import { BreakpointSystem } from './BreakpointSystem'; import { CommonConstants } from '../common/CommonConstants'; +import Logger from './Logger'; const TAG: string = '[WindowUtil]'; @@ -30,7 +30,7 @@ export class WindowUtil { WindowUtil.requestFullScreen(); WindowUtil.registerBreakPoint(); } catch (err) { - hilog.error(0x0000, TAG, `WindowUtil initialize Failed. Cause: ${err.message}`); + Logger.error(TAG, `WindowUtil initialize Failed. Cause: ${err.message}`); } } @@ -39,13 +39,13 @@ export class WindowUtil { try { const promise: Promise = WindowUtil.windowClass.setWindowLayoutFullScreen(true); promise.then(() => { - hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); + Logger.info(TAG, 'Succeeded in setting the window layout to full-screen mode.'); }).catch((err: BusinessError) => { - hilog.error(0x0000, TAG, + Logger.error(TAG, `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); }); } catch { - hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. '); + Logger.error(TAG, 'Failed to set the window layout to full-screen mode. '); } } @@ -59,19 +59,27 @@ export class WindowUtil { } private static updateAvoidArea(windowObj: window.Window) { - WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_SYSTEM, - windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)); - WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR, - windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)); + try { + WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_SYSTEM, + windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)); + WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR, + windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)); + } catch (err) { + Logger.error(TAG, 'getWindowAvoidArea get exception'); + } } // Get status bar height and indicator height. private static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { - let uiContext = WindowUtil.windowClass.getUIContext(); - if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT, uiContext.px2vp(area.topRect.height)); - } else if (type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { - AppStorage.setOrCreate(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT, uiContext.px2vp(area.bottomRect.height)); + try { + let uiContext = WindowUtil.windowClass.getUIContext(); + if (type === window.AvoidAreaType.TYPE_SYSTEM) { + AppStorage.setOrCreate(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT, uiContext.px2vp(area.topRect.height)); + } else if (type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + AppStorage.setOrCreate(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT, uiContext.px2vp(area.bottomRect.height)); + } + } catch (err) { + Logger.error(TAG, 'getUIContext get exception'); } } } \ No newline at end of file diff --git a/pickersample/src/main/ets/entryability/EntryAbility.ets b/pickersample/src/main/ets/entryability/EntryAbility.ets index 78331a49e1260f5a748c9013692499b4838cdff4..31ef4f3fd56845d28f3d67c2ac9af70bf973bf37 100644 --- a/pickersample/src/main/ets/entryability/EntryAbility.ets +++ b/pickersample/src/main/ets/entryability/EntryAbility.ets @@ -15,46 +15,28 @@ import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { PickerController } from '@ohos_samples/pickerlibrary'; +import { Logger, PickerController } from '@ohos_samples/pickerlibrary'; const TAG = 'EntryAbility: '; export default class EntryAbility extends UIAbility { onCreate(): void { - hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate'); - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - } - - onDestroy(): void { - hilog.info(0x0000, TAG, '%{public}s', 'Ability onDestroy'); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + Logger.error(TAG, `Failed to setColorMode. Cause: ${JSON.stringify(err)}`); + } } onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability - hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { - hilog.error(0x0000, TAG, `Failed to load the content, code: ${err.code}, message: ${err.message}}.`); + Logger.error(TAG, `Failed to load the content, err code: ${err.code}, message: ${err.message}`); return; } PickerController.initWindowConfig(windowStage); - hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in loading the content.'); + Logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); }); } - - onWindowStageDestroy(): void { - // Main window is destroyed, release UI related resources - hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy'); - } - - onForeground(): void { - // Ability has brought to foreground - hilog.info(0x0000, TAG, '%{public}s', 'Ability onForeground'); - } - - onBackground(): void { - // Ability has back to background - hilog.info(0x0000, TAG, '%{public}s', 'Ability onBackground'); - } } \ No newline at end of file