diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 9c5a1393305885af2651f40104a0a8a841837bfe..0d332c6a5669c2e0bd3706139e08060a42206446 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -67,7 +67,13 @@ export default class EntryAbility extends UIAbility { windowStage.getMainWindow().then((windowObj: window.Window) => { windowObj.on('windowSizeChange', (windowSize) => { this.updateBreakpoint(windowSize.width); - }) + }); + windowObj.setWindowLayoutFullScreen(true).then(() => { + hilog.info(0x0000, TAG, `%{public}s`, 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((error: BusinessError) => { + hilog.error(0x0000, TAG, '%{public}s', + `UFailed to set the window layout to full-screen mode. code: ${error.code}, message: ${error.message}`); + }); }).catch((error: BusinessError) => { hilog.error(0x0000, TAG, '%{public}s', `Failed to get main window. code: ${error.code}, message: ${error.message}`); @@ -81,13 +87,6 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in loading the content.'); - let windowClass: window.Window = windowStage.getMainWindowSync(); - windowClass.setWindowLayoutFullScreen(true).then(() => { - hilog.info(0x0000, TAG, `%{public}s`, 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((error: BusinessError) => { - hilog.error(0x0000, TAG, '%{public}s', - `UFailed to set the window layout to full-screen mode. code: ${error.code}, message: ${error.message}`); - }); }); }