diff --git a/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets b/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets index 48d7c5ca0b9628bd20fca1d728108eb621b8cd1a..9a063bbb6c27ddc58c0d24e4dee5944d630b75db 100644 --- a/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets +++ b/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets @@ -26,7 +26,11 @@ const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -36,10 +40,10 @@ export default class EntryAbility extends UIAbility { // [Start extract_screen_adaption] onWindowStageCreate(windowStage: window.WindowStage): void { - AppStorage.setOrCreate('context', windowStage); - windowStage.getMainWindow((err: BusinessError, data) => { + AppStorage.setOrCreate('context', this.context); + windowStage.getMainWindow((err: BusinessError, window: window.Window) => { // The settings window is displayed in full screen - data.setWindowLayoutFullScreen(true) + window.setWindowLayoutFullScreen(true) .then(() => { console.info('Succeeded in setting the window layout to full-screen mode.'); }).catch((err: BusinessError) => { @@ -47,7 +51,7 @@ export default class EntryAbility extends UIAbility { }); // Set the top status bar to be hidden let names: Array<'status' | 'navigation'> = []; - data.setWindowSystemBarEnable(names) + window.setWindowSystemBarEnable(names) .then(() => { console.info('Succeeded in setting the system bar to be invisible.'); }).catch((err: BusinessError) => { diff --git a/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets b/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets index 6635c82299749469c60f268405654db48fbf6361..84c02f9a3e7ca81b392a9839baeb333f7c5ce712 100644 --- a/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets +++ b/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets @@ -37,8 +37,7 @@ struct Index { @State screenWidth: number = 0; // Screen width @State displayClass: display.Display | null = null; @State topTextMargin: TextMargin = { left: 0, right: 0 }; // Top status bar offset - @StorageLink('context') context: common.UIAbilityContext | undefined = - AppStorage.get('context'); // Get UIAbilityContext + @StorageLink('context') context: common.UIAbilityContext | undefined = AppStorage.get('context'); // Get UIAbilityContext aboutToAppear(): void { try {