diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 6335521e2b5845a587af32e2f172e2bbbfda7737..a1843d5967d83aa88a3ac823aebb52b2b7c3c166 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -41,7 +41,7 @@ export default class EntryAbility extends UIAbility { } catch (error) { const err = error as BusinessError; hilog.error(0x000, TAG, `updateBreakpoint catch err: code: ${err.code}, message: ${err.message}`); - }; + } } onCreate(): void { @@ -77,6 +77,8 @@ export default class EntryAbility extends UIAbility { const err = error as BusinessError; hilog.error(0x000, TAG, `onWindowStageCreate catch err, code: ${err.code}, message: ${err.message}`); } + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', `Failed to get main window. Cause:`, err.message); }); windowStage.loadContent('pages/Index', (err) => { @@ -85,14 +87,19 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); - 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}`); - }); + 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) => {