diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index a1843d5967d83aa88a3ac823aebb52b2b7c3c166..5d6b5dd2c91f477e364c0213aca456237deaefd4 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -73,6 +73,12 @@ export default class EntryAbility extends UIAbility { windowObj.on('windowSizeChange', (windowSize) => { this.updateBreakpoint(windowSize.width); }) + windowObj.setWindowLayoutFullScreen(true).then(() => { + hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, TAG, + `Failed to set the window layout to full-screen mode, err code: ${err.code}, message: ${err.message}`); + }); } catch (error) { const err = error as BusinessError; hilog.error(0x000, TAG, `onWindowStageCreate catch err, code: ${err.code}, message: ${err.message}`); @@ -87,19 +93,6 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); - try { - let windowClass: window.Window = windowStage.getMainWindowSync(); - let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { - hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, TAG, - `Failed to set the window layout to full-screen mode, err code: ${err.code}, message: ${err.message}`); - }); - } catch (error) { - const err = error as BusinessError; - hilog.error(0x000, TAG, `Set window layout to full-screen err, code: ${err.code}, message: ${err.message}`); - } }); let windowClass: window.Window | undefined = undefined; window.getLastWindow(this.context, (err: BusinessError, data) => {