diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md
index 02c4680e1e082798d81c692cb178ca72fe21cf9a..199469589d8a67a47b993eacc36eac69a25aa8c1 100644
--- a/en/application-dev/reference/apis/js-apis-display.md
+++ b/en/application-dev/reference/apis/js-apis-display.md
@@ -11,7 +11,6 @@ The **Display** module provides APIs for managing displays, such as obtaining in
import display from '@ohos.display';
```
-
## DisplayState
Enumerates the display states.
@@ -65,61 +64,6 @@ Describes the cutout, which is an area that is not intended for displaying conte
| boundingRects | Array\<[Rect](#rect9)> | Yes | No | Bounding rectangle for punch holes and notches.|
| waterfallDisplayAreaRects | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | Yes| No| Curved area on the waterfall display.|
-## display.getDefaultDisplay
-
-getDefaultDisplay(callback: AsyncCallback<Display>): void
-
-Obtains the default display object. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<[Display](#display)> | Yes| Callback used to return the default display object.|
-
-**Example**
-
-```js
-var displayClass = null;
-display.getDefaultDisplay((err, data) => {
- if (err.code) {
- console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
- displayClass = data;
-});
-```
-
-## display.getDefaultDisplay
-
-getDefaultDisplay(): Promise<Display>
-
-Obtains the default display object. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Return value**
-
- | Type | Description |
- | ---------------------------------- | ---------------------------------------------- |
- | Promise<[Display](#display)> | Promise used to return the default display object.|
-
-**Example**
-
-```js
-var displayClass = null;
-let promise = display.getDefaultDisplay();
-promise.then((data) => {
- displayClass = data;
- console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
-});
-```
-
## display.getDefaultDisplaySync9+
getDefaultDisplaySync(): Display
@@ -134,15 +78,28 @@ Obtains the default display object. This API returns the result synchronously.
| ------------------------------| ----------------------------------------------|
| [Display](#display) | Default display object.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
```js
-var displayClass = display.getDefaultDisplaySync();
+let displayClass = null;
+try {
+ displayClass = display.getDefaultDisplaySync();
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
+};
```
-## display.getAllDisplay
+## display.getAllDisplays9+
-getAllDisplay(callback: AsyncCallback<Array<Display>>): void
+getAllDisplays(callback: AsyncCallback<Array<Display>>): void
Obtains all display objects. This API uses an asynchronous callback to return the result.
@@ -150,14 +107,24 @@ Obtains all display objects. This API uses an asynchronous callback to return th
**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | ---------------------------------------------------- | ---- | ------------------------------- |
- | callback | AsyncCallback<Array<[Display](#display)>> | Yes | Callback used to return all the display objects.|
+| Name| Type| Mandatory| Description|
+| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
+| callback | AsyncCallback<Array<[Display](#display)>> | Yes| Callback used to return all the display objects.|
+
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
**Example**
```js
-display.getAllDisplay((err, data) => {
+let displayClass = null;
+display.getAllDisplays((err, data) => {
+ displayClass = data;
if (err.code) {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
return;
@@ -166,9 +133,9 @@ display.getAllDisplay((err, data) => {
});
```
-## display.getAllDisplay
+## display.getAllDisplays9+
-getAllDisplay(): Promise<Array<Display>>
+getAllDisplays(): Promise<Array<Display>>
Obtains all display objects. This API uses a promise to return the result.
@@ -176,15 +143,25 @@ Obtains all display objects. This API uses a promise to return the result.
**Return value**
- | Type | Description |
- | ----------------------------------------------- | ------------------------------------------------------- |
- | Promise<Array<[Display](#display)>> | Promise used to return all the display objects.|
+| Type| Description|
+| ----------------------------------------------- | ------------------------------------------------------- |
+| Promise<Array<[Display](#display)>> | Promise used to return all the display objects.|
+
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
**Example**
```js
-let promise = display.getAllDisplay();
+let displayClass = null;
+let promise = display.getAllDisplays();
promise.then((data) => {
+ displayClass = data;
console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
@@ -195,7 +172,7 @@ promise.then((data) => {
hasPrivateWindow(displayId: number): boolean
-Checks whether there is a visible privacy window on a display. The privacy window can be set by calling `[setPrivacyMode](js-apis-window.md#setprivacymode7)`. The content in the privacy window cannot be captured or recorded.
+Checks whether there is a visible privacy window on a display. The privacy window can be set by calling [setWindowPrivacyMode()](js-apis-window.md#setwindowprivacymode9). The content in the privacy window cannot be captured or recorded.
**System API**: This is a system API.
@@ -211,30 +188,41 @@ Checks whether there is a visible privacy window on a display. The privacy windo
| Type | Description |
| -------------------------------- |-----------------------------------------------------------------------|
-|boolean | Whether there is a visible privacy window on the display.
The value `true` means that there is a visible privacy window on the display, and `false` means the opposite.
|
+|boolean | Whether there is a visible privacy window on the display.
The value **true** means that there is a visible privacy window on the display, and **false** means the opposite.
|
+
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
**Example**
```js
-var displayClass = null;
-display.getDefaultDisplay((err, data) => {
- if (err.code) {
- console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
+let displayClass = null;
+try {
+ displayClass = display.getDefaultDisplaySync();
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
- }
- console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
- displayClass = data;
-});
-
-var ret = display.hasPrivateWindow(displayClass.id);
+};
+
+let ret = undefined;
+try {
+ ret = display.hasPrivateWindow(displayClass.id);
+} catch (exception) {
+ console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
+};
if (ret == undefined) {
- console.log("Failed to check has privateWindow or not.");
+ console.log("Failed to check has privateWindow or not.");
}
if (ret) {
console.log("There has privateWindow.");
} else if (!ret) {
console.log("There has no privateWindow.");
-}
+};
```
## display.on('add'|'remove'|'change')
@@ -249,16 +237,20 @@ Subscribes to display changes.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes| Event type.
- **add**, indicating the display addition event.
- **remove**, indicating the display removal event.
- **change**, indicating the display change event.|
+| type | string | Yes| Event type.
- **add**, indicating the display addition event. Example: event indicating that a display is connected to a PC.
- **remove**, indicating the display removal event. Example: event that a display is disconnected from a PC.
- **change**, indicating the display change event. Example: event that the display orientation is changed.|
| callback | Callback<number> | Yes| Callback used to return the ID of the display.|
**Example**
```js
-var callback = (data) => {
+let callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data));
-}
-display.on("add", callback);
+};
+try {
+ display.on("add", callback);
+} catch (exception) {
+ console.error('Failed to register callback. Code: ' + JSON.stringify(exception));
+};
```
## display.off('add'|'remove'|'change')
@@ -271,21 +263,147 @@ Unsubscribes from display changes.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type.
- **add**, indicating the display addition event.
- **remove**, indicating the display removal event.
- **change**, indicating the display change event.|
- | callback | Callback<number> | No| Callback used to return the ID of the display.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type.
- **add**, indicating the display addition event. Example: event indicating that a display is connected to a PC.
- **remove**, indicating the display removal event. Example: event that a display is disconnected from a PC.
- **change**, indicating the display change event. Example: event that the display orientation is changed.|
+| callback | Callback<number> | No| Callback used to return the ID of the display.|
+
+**Example**
+
+```js
+try {
+ display.off("remove");
+} catch (exception) {
+ console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception));
+};
+```
+
+## display.getDefaultDisplay(deprecated)
+
+getDefaultDisplay(callback: AsyncCallback<Display>): void
+
+Obtains the default display object. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<[Display](#display)> | Yes| Callback used to return the default display object.|
+
+**Example**
+
+```js
+let displayClass = null;
+display.getDefaultDisplay((err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
+ displayClass = data;
+});
+```
+
+## display.getDefaultDisplay(deprecated)
+
+getDefaultDisplay(): Promise<Display>
+
+Obtains the default display object. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------- | ---------------------------------------------- |
+| Promise<[Display](#display)> | Promise used to return the default display object.|
+
+**Example**
+
+```js
+let displayClass = null;
+let promise = display.getDefaultDisplay();
+promise.then((data) => {
+ displayClass = data;
+ console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
+}).catch((err) => {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
+});
+```
+
+## display.getAllDisplay(deprecated)
+
+getAllDisplay(callback: AsyncCallback<Array<Display>>): void
+
+Obtains all display objects. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
+| callback | AsyncCallback<Array<[Display](#display)>> | Yes | Callback used to return all the display objects.|
**Example**
```js
-display.off("remove");
+display.getAllDisplay((err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
+});
+```
+
+## display.getAllDisplay(deprecated)
+
+getAllDisplay(): Promise<Array<Display>>
+
+Obtains all display objects. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9-1) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------- | ------------------------------------------------------- |
+| Promise<Array<[Display](#display)>> | Promise used to return all the display objects.|
+
+**Example**
+
+```js
+let promise = display.getAllDisplay();
+promise.then((data) => {
+ console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
+}).catch((err) => {
+ console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
+});
```
## Display
-Implements a `Display` instance, with properties and APIs defined.
+Implements a **Display** instance, with properties and APIs defined.
-To call an API in the following API examples, you must first use `[getAllDisplay()](#displaygetalldisplay)`, `[getDefaultDisplay()](#displaygetdefaultdisplay)`, or `[getDefaultDisplaySync()](#displaygetdefaultdisplaysync)` to obtain a `Display` instance.
+Before calling any API in **Display**, you must use [getAllDisplays()](#displaygetalldisplays9) or [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) to obtain a **Display** instance.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
@@ -296,7 +414,7 @@ To call an API in the following API examples, you must first use `[getAllDisplay
| alive | boolean | Yes| No| Whether the display is alive.|
| state | [DisplayState](#displaystate) | Yes| No| State of the display.|
| refreshRate | number | Yes| No| Refresh rate of the display.|
-| rotation | number | Yes| No| Screen rotation angle of the display.|
+| rotation | number | Yes| No| Screen rotation angle of the display.
The value **0** indicates that the screen of the display rotates by 0°.
The value **1** indicates that the screen of the display rotates by 90°.
The value **2** indicates that the screen of the display rotates by 180°.
The value **3** indicates that the screen of the display rotates by 270°.|
| width | number | Yes| No| Width of the display, in pixels.|
| height | number | Yes| No| Height of the display, in pixels.|
| densityDPI | number | Yes| No| Screen density of the display, in DPI.|
@@ -308,29 +426,46 @@ To call an API in the following API examples, you must first use `[getAllDisplay
### getCutoutInfo9+
getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void
-Obtains the cutout information of the display. This API uses an asynchronous callback to return the result.
+Obtains the cutout information of the display. This API uses an asynchronous callback to return the result. You are advised not to use the cutout area during application layout.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
-| callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | Yes | Callback used to If the operation is successful, `err` is `undefined` and `data` is the `CutoutInfo` object obtained. Otherwise, `err` is an error object.|
+| callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the **CutoutInfo** object obtained. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
**Example**
```js
+let displayClass = null;
+try {
+ displayClass = display.getDefaultDisplaySync();
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
+};
+
displayClass.getCutoutInfo((err, data) => {
if (err.code) {
- console.error('Failed to get cutoutInfo. Cause: ' + JSON.stringify(err));
+ console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
-})
+});
```
### getCutoutInfo9+
getCutoutInfo(): Promise<CutoutInfo>
-Obtains the cutout information of the display. This API uses a promise to return the result.
+Obtains the cutout information of the display. This API uses a promise to return the result. You are advised not to use the cutout area during application layout.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
@@ -338,11 +473,26 @@ Obtains the cutout information of the display. This API uses a promise to return
| Type | Description |
| ------------------- | ------------------------- |
-| Promise<[CutoutInfo](#cutoutinfo9)> | Promise used to return the `CutoutInfo` object.|
+| Promise<[CutoutInfo](#cutoutinfo9)> | Promise used to return the **CutoutInfo** object.|
+
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
**Example**
```js
+let displayClass = null;
+try {
+ displayClass = display.getDefaultDisplaySync();
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
+};
+
let promise = displayClass.getCutoutInfo();
promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
diff --git a/en/application-dev/reference/apis/js-apis-screen.md b/en/application-dev/reference/apis/js-apis-screen.md
index 73ea5d3c915d2ba91c129ed8d7c8ed80efe8170d..47cb10179c1d12d9bd7d010b9db08dc316b57f7f 100644
--- a/en/application-dev/reference/apis/js-apis-screen.md
+++ b/en/application-dev/reference/apis/js-apis-screen.md
@@ -1,4 +1,5 @@
# Screen
+
The **Screen** module implements basic screen management. You can use the APIs of this module to obtain a **Screen** object, listen for screen changes, and create and destroy virtual screens.
> **NOTE**
@@ -6,6 +7,7 @@ The **Screen** module implements basic screen management. You can use the APIs o
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
+
## Modules to Import
```js
@@ -26,19 +28,28 @@ Obtains all screens. This API uses an asynchronous callback to return the result
| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback<Array<[Screen](#screen)>> | Yes | Callback used to return all the **Screen** objects obtained.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
```js
-var screenClass = null;
+let screenClass = null;
screen.getAllScreens((err, data) => {
if (err.code) {
- console.error('Failed to get all screens . Cause: ' + JSON.stringify(err));
+ console.error('Failed to get all screens. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in getting all screens . Data:' + JSON.stringify(data));
+ console.info('Succeeded in getting all screens. Data:' + JSON.stringify(data));
screenClass = data[0];
});
```
+
## screen.getAllScreens
getAllScreens(): Promise<Array<Screen>>
@@ -48,22 +59,34 @@ Obtains all screens. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
+
| Type | Description |
| --------------------------------------------- | ----------------------------------------- |
| Promise<Array<[Screen](#screen)>> | Promise used to return all the **Screen** objects obtained.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-var screenClass = null;
+let screenClass = null;
let promise = screen.getAllScreens();
promise.then((data) => {
screenClass = data[0];
- console.log('Succeeded in getting all screens . Data:'+ JSON.stringify(data));
+ console.log('Succeeded in getting all screens. Data:'+ JSON.stringify(data));
}).catch((err) => {
- console.log('Failed to get all screens . Cause: ' + JSON.stringify(err));
+ console.log('Failed to get all screens. Cause: ' + JSON.stringify(err));
});
```
+
## screen.on('connect' | 'disconnect' | 'change')
+
on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback<number>): void
Subscribes to events related to the screen state.
@@ -71,19 +94,27 @@ Subscribes to events related to the screen state.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
+
| Name | Type | Mandatory| Description |
| --------- | ---------------------- | ---- | ------------------------------------------------------------ |
| eventType | string | Yes | Event type.
- **connect**: an event indicating that the screen is connected.
- **disconnect**: an event indicating that the screen is disconnected.
- **change**: an event indicating that the screen state changes.|
| callback | Callback<number> | Yes | Callback used to return the screen ID. |
**Example**
+
```js
-var callback = (data) => {
- console.info('Register the callback for screen changes. Data: ' + JSON.stringify(data))
+try {
+ let callback = (data) => {
+ console.info('Succeeded in registering the callback for screen changes. Data: ' + JSON.stringify(data))
+ };
+ screen.on('connect', callback);
+} catch (exception) {
+ console.error('Failed to register the callback for screen changes. Code: ' + JSON.stringify(exception));
};
-screen.on("connect", callback);
```
+
## screen.off('connect' | 'disconnect' | 'change')
+
off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<number>): void
Unsubscribes from events related to the screen state.
@@ -91,20 +122,27 @@ Unsubscribes from events related to the screen state.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
+
| Name | Type | Mandatory| Description |
| --------- | ---------------------- | ---- | ------------------------------------------------------------ |
| eventType | string | Yes | Event type.
- **connect**: an event indicating that the screen is connected.
- **disconnect**: an event indicating that the screen is disconnected.
- **change**: an event indicating that the screen state changes.|
| callback | Callback<number> | No | Callback used to return the screen ID. |
**Example**
+
```js
-var callback = (data) => {
- console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data))
+try {
+ let callback = (data) => {
+ console.info('Succeeded in unregistering the callback for screen changes. Data: ' + JSON.stringify(data))
+ };
+ screen.off('connect', callback);
+} catch (exception) {
+ console.error('Failed to register the callback for screen changes. Code: ' + JSON.stringify(exception));
};
-screen.off("connect", callback);
```
## screen.makeExpand
+
makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number>): void
Sets the screen to the expanded mode. This API uses an asynchronous callback to return the result.
@@ -112,26 +150,40 @@ Sets the screen to the expanded mode. This API uses an asynchronous callback to
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
+
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | ---- | -------------------------------- |
| options | Array<[ExpandOption](#expandoption)> | Yes | Parameters for expanding the screen. |
| callback | Callback<number> | Yes | Callback used to return the group ID of the expanded screens.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
```js
-var groupId = null;
-screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}], (err, data) => {
- if (err.code) {
- console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err));
- return;
- }
- groupId = data;
- console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data));
-});
+try {
+ let groupId = null;
+ screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}], (err, data) => {
+ if (err.code) {
+ console.error('Failed to expand the screen. Code:' + JSON.stringify(err));
+ return;
+ }
+ groupId = data;
+ console.info('Succeeded in expanding the screen. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to expand the screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.makeExpand
+
makeExpand(options:Array<ExpandOption>): Promise<number>
Sets the screen to the expanded mode. This API uses a promise to return the result.
@@ -145,20 +197,35 @@ Sets the screen to the expanded mode. This API uses a promise to return the resu
| options | Array<[ExpandOption](#expandoption)> | Yes | Parameters for expanding the screen.|
**Return value**
+
| Type | Description |
| --------------------- | ----------------------------------- |
| Promise<number> | Promise used to return the group ID of the expanded screens.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}]).then((data) => {
- console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err));
-});
+try {
+ screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}]).then((data) => {
+ console.info('Succeeded in expanding the screen. Data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to expand the screen. Code:' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to expand the screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.makeMirror
+
makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncCallback<number>): void
Sets screen mirroring. This API uses an asynchronous callback to return the result.
@@ -173,20 +240,34 @@ Sets screen mirroring. This API uses an asynchronous callback to return the resu
| mirrorScreen | Array<number> | Yes | IDs of secondary screens. |
| callback | AsyncCallback<number> | Yes | Callback used to return the group ID of the secondary screens.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-var mainScreenId = 0;
-var mirrorScreenIds = [1, 2, 3];
-screen.makeMirror(mainScreenId, mirrorScreenIds, (err, data) => {
- if (err.code) {
- console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data));
-});
+let mainScreenId = 0;
+let mirrorScreenIds = [1, 2, 3];
+try {
+ screen.makeMirror(mainScreenId, mirrorScreenIds, (err, data) => {
+ if (err.code) {
+ console.error('Failed to set screen mirroring. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting screen mirroring. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to set screen mirroring. Code: ' + JSON.stringify(exception));
+};
```
## screen.makeMirror
+
makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<number>
Sets screen mirroring. This API uses a promise to return the result.
@@ -201,22 +282,37 @@ Sets screen mirroring. This API uses a promise to return the result.
| mirrorScreen | Array<number> | Yes | IDs of secondary screens.|
**Return value**
+
| Type | Description |
| --------------------- | ----------------------------------- |
| Promise<number> | Promise used to return the group ID of the secondary screens.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-var mainScreenId = 0;
-var mirrorScreenIds = [1, 2, 3];
-screen.makeMirror(mainScreenId, mirrorScreenIds).then((data) => {
- console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err));
-});
+let mainScreenId = 0;
+let mirrorScreenIds = [1, 2, 3];
+try {
+ screen.makeMirror(mainScreenId, mirrorScreenIds).then((data) => {
+ console.info('Succeeded in setting screen mirroring. Data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to set screen mirroring. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set screen mirroring. Code: ' + JSON.stringify(exception));
+};
```
## screen.createVirtualScreen
+
createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Screen>): void
Creates a virtual screen. This API uses an asynchronous callback to return the result.
@@ -232,35 +328,50 @@ Creates a virtual screen. This API uses an asynchronous callback to return the r
| options | [VirtualScreenOption](#virtualscreenoption) | Yes | Virtual screen parameters. |
| callback | AsyncCallback<[Screen](#screen)> | Yes | Callback used to return the created virtual screen.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-var screenClass = null;
-screen.createVirtualScreen({
- name: 'screen01',
- width: 1080,
- height: 2340,
- density: 2,
- surfaceId: ''
-}, (err, data) => {
- if (err.code) {
- console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err));
- return;
- }
- screenClass = data;
- console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data));
-});
+let screenClass = null;
+try {
+ screen.createVirtualScreen({
+ name: 'screen01',
+ width: 1080,
+ height: 2340,
+ density: 2,
+ surfaceId: ''
+ }, (err, data) => {
+ if (err.code) {
+ console.error('Failed to create the virtual screen. Code: ' + JSON.stringify(err));
+ return;
+ }
+ screenClass = data;
+ console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to create the virtual screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.createVirtualScreen
+
createVirtualScreen(options:VirtualScreenOption): Promise<Screen>
Creates a virtual screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-**Required permissions**: ohos.permission.CAPTURE_SCREEN (mandatory when **VirtualScreenOption.surfaceId** is valid available only to system applications)
+**Required permissions**: ohos.permission.CAPTURE_SCREEN (mandatory when **VirtualScreenOption.surfaceId** is valid; available only to system applications)
**Parameters**
+
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | ------------------------ |
| options | [VirtualScreenOption](#virtualscreenoption) | Yes | Virtual screen parameters.|
@@ -271,24 +382,38 @@ Creates a virtual screen. This API uses a promise to return the result.
| -------------------------------- | ------------------------------------- |
| Promise<[Screen](#screen)> | Promise used to return the created virtual screen.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-var screenClass = null;
-screen.createVirtualScreen({
- name: 'screen01',
- width: 1080,
- height: 2340,
- density: 2,
- surfaceId: ''
-}).then((data) => {
- screenClass = data;
- console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err));
-});
+let screenClass = null;
+try {
+ screen.createVirtualScreen({
+ name: 'screen01',
+ width: 1080,
+ height: 2340,
+ density: 2,
+ surfaceId: ''
+ }).then((data) => {
+ screenClass = data;
+ console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to create the virtual screen. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to create the virtual screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.destroyVirtualScreen
+
destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void
Destroys a virtual screen. This API uses an asynchronous callback to return the result.
@@ -296,24 +421,39 @@ Destroys a virtual screen. This API uses an asynchronous callback to return the
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
+
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| screenId | number | Yes | Screen ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the virtual screen is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------------- |
+| 1400002 | Unauthorized operation. |
+
**Example**
+
```js
-var screenId = 1;
-screen.destroyVirtualScreen(screenId, (err,data) => {
- if (err.code) {
- console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in destroying virtual screen.');
-});
+let screenId = 1;
+try {
+ screen.destroyVirtualScreen(screenId, (err,data) => {
+ if (err.code) {
+ console.error('Failed to destroy the virtual screen. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in destroying the virtual screen.');
+ });
+} catch (exception) {
+ console.error('Failed to destroy the virtual screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.destroyVirtualScreen
+
destroyVirtualScreen(screenId:number): Promise<void>
Destroys a virtual screen. This API uses a promise to return the result.
@@ -321,26 +461,42 @@ Destroys a virtual screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
+
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------- |
| screenId | number | Yes | Screen ID.|
**Return value**
+
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------------- |
+| 1400002 | Unauthorized operation. |
+
**Example**
+
```js
-var screenId = 1;
-screen.destroyVirtualScreen(screenId).then((data) => {
- console.info('Succeeded in destroying virtual screen.');
-}).catch((err) => {
- console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err));
-});
+let screenId = 1;
+try {
+ screen.destroyVirtualScreen(screenId).then((data) => {
+ console.info('Succeeded in destroying the virtual screen.');
+ }).catch((err) => {
+ console.error('Failed to destroy the virtual screen. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to destroy the virtual screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.setVirtualScreenSurface
+
setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback<void>): void
Sets the surface for a virtual screen. This API uses an asynchronous callback to return the result.
@@ -357,21 +513,34 @@ Sets the surface for a virtual screen. This API uses an asynchronous callback to
| surfaceId | string | Yes | Surface ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the virtual screen surface is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
```js
-var screenId = 1;
-var surfaceId = '2048';
-screen.setVirtualScreenSurface(screenId, surfaceId, (err,data) => {
- if (err.code) {
- console.error('Failed to set surface for the virtual screen. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting surface for the virtual screen.');
-});
+let screenId = 1;
+let surfaceId = '2048';
+try {
+ screen.setVirtualScreenSurface(screenId, surfaceId, (err,data) => {
+ if (err.code) {
+ console.error('Failed to set the surface for the virtual screen. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the surface for the virtual screen.');
+ });
+} catch (exception) {
+ console.error('Failed to set the surface for the virtual screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.setVirtualScreenSurface
+
setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void>
Sets the surface for a virtual screen. This API uses a promise to return the result.
@@ -381,28 +550,44 @@ Sets the surface for a virtual screen. This API uses a promise to return the res
**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications)
**Parameters**
+
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------- |
| screenId | number | Yes | Screen ID. |
| surfaceId | string | Yes | Surface ID.|
**Return value**
+
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | ----------------------- |
+| 1400001 | Invalid display or screen. |
+
**Example**
+
```js
-var screenId = 1;
-var surfaceId = '2048';
-screen.setVirtualScreenSurface(screenId, surfaceId).then((data) => {
- console.info('Succeeded in setting surface for the virtual screen.');
-}).catch((err) => {
- console.error('Failed to set surface for the virtual screen. Cause:' + JSON.stringify(err));
-});
+let screenId = 1;
+let surfaceId = '2048';
+try {
+ screen.setVirtualScreenSurface(screenId, surfaceId).then((data) => {
+ console.info('Succeeded in setting the surface for the virtual screen.');
+ }).catch((err) => {
+ console.error('Failed to set the surface for the virtual screen. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the surface for the virtual screen. Code: ' + JSON.stringify(exception));
+};
```
## screen.isScreenRotationLocked
+
isScreenRotationLocked(): Promise<boolean>
Checks whether auto rotate is locked. This API uses a promise to return the result.
@@ -410,20 +595,23 @@ Checks whether auto rotate is locked. This API uses a promise to return the resu
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
+
| Type | Description |
| ---------------------- | ------------------------------------- |
| Promise<boolean> | Promise used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.|
**Example**
+
```js
screen.isScreenRotationLocked().then((isLocked) => {
- console.info('Succeeded in getting screen rotation lock status. isLocked:'+ JSON.stringify(isLocked));
+ console.info('Succeeded in getting the screen rotation lock status. isLocked:'+ JSON.stringify(isLocked));
}).catch((err) => {
- console.error('Failed to get screen rotation lock status. Cause:' + JSON.stringify(err));
+ console.error('Failed to get the screen rotation lock status. Cause:' + JSON.stringify(err));
});
```
## screen.isScreenRotationLocked
+
isScreenRotationLocked(callback: AsyncCallback<boolean>): void
Checks whether auto rotate is locked. This API uses an asynchronous callback to return the result.
@@ -441,14 +629,15 @@ Checks whether auto rotate is locked. This API uses an asynchronous callback to
```js
screen.isScreenRotationLocked((err, isLocked) => {
if (err.code) {
- console.error('Failed to get screen rotation lock status. Cause:' + JSON.stringify(err));
+ console.error('Failed to get the screen rotation lock status. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in getting screen rotation lock status. isLocked:' + JSON.stringify(isLocked));
+ console.info('Succeeded in getting the screen rotation lock status. isLocked:' + JSON.stringify(isLocked));
});
```
## screen.setScreenRotationLocked
+
setScreenRotationLocked(isLocked: boolean): Promise<void>
Sets whether to lock auto rotate. This API uses a promise to return the result.
@@ -456,26 +645,34 @@ Sets whether to lock auto rotate. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
+
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------- |
| isLocked | boolean | Yes | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite.|
**Return value**
+
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
**Example**
+
```js
-var isLocked = false;
-screen.setScreenRotationLocked(isLocked).then((data) => {
- console.info('Succeeded in setting whether to lock screen rotation');
-}).catch((err) => {
- console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err));
-});
+let isLocked = false;
+try {
+ screen.setScreenRotationLocked(isLocked).then((data) => {
+ console.info('Succeeded in unlocking auto rotate');
+ }).catch((err) => {
+ console.error('Failed to unlock auto rotate. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to unlock auto rotate. Code: ' + JSON.stringify(exception));
+};
```
## screen.setScreenRotationLocked
+
setScreenRotationLocked(isLocked: boolean, callback: AsyncCallback<void>): void
Sets whether to lock auto rotate. This API uses an asynchronous callback to return the result.
@@ -492,17 +689,22 @@ Sets whether to lock auto rotate. This API uses an asynchronous callback to retu
**Example**
```js
-var isLocked = false;
-screen.setScreenRotationLocked(isLocked, (err, data) => {
- if (err.code) {
- console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting whether to lock screen rotation.');
-});
+let isLocked = false;
+try {
+ screen.setScreenRotationLocked(isLocked, (err, data) => {
+ if (err.code) {
+ console.error('Failed to unlock auto rotate. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in unlocking auto rotate.');
+ });
+} catch (exception) {
+ console.error('Failed to unlock auto rotate. Code: ' + JSON.stringify(exception));
+};
```
## ExpandOption
+
Defines the parameters for expanding a screen.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
@@ -514,6 +716,7 @@ Defines the parameters for expanding a screen.
| startY | number | Yes | Yes | Start Y coordinate of the screen.|
## VirtualScreenOption
+
Defines virtual screen parameters.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
@@ -527,6 +730,7 @@ Defines virtual screen parameters.
| surfaceId | string | Yes | Yes | Surface ID of the virtual screen.|
## Screen
+
Implements a **Screen** instance.
Before calling any API in **Screen**, you must use **[getAllScreens()](#screengetallscreens)** or **[createVirtualScreen()](#screencreatevirtualscreen)** to obtain a **Screen** instance.
@@ -542,6 +746,7 @@ Before calling any API in **Screen**, you must use **[getAllScreens()](#screenge
| orientation | [Orientation](#orientation) | Yes | No | Screen orientation. |
### setOrientation
+
setOrientation(orientation: Orientation, callback: AsyncCallback<void>): void
Sets the screen orientation. This API uses an asynchronous callback to return the result.
@@ -553,17 +758,32 @@ Sets the screen orientation. This API uses an asynchronous callback to return th
| orientation | [Orientation](#orientation) | Yes | Screen orientation. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the screen orientation is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
+
**Example**
+
```js
-screenClass.setOrientation(screen.Orientation.VERTICAL, (err, data) => {
- if (err.code) {
- console.error('Failed to setOrientation VERTICAL. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting Orientation VERTICAL. data: ' + JSON.stringify(data));
-})
+try {
+ screenClass.setOrientation(screen.Orientation.VERTICAL, (err, data) => {
+ if (err.code) {
+ console.error('Failed to set the vertical orientation. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the vertical orientation. data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to set the vertical orientation. Code: ' + JSON.stringify(exception));
+};
```
+
### setOrientation
+
setOrientation(orientation: Orientation): Promise<void>
Sets the screen orientation. This API uses a promise to return the result.
@@ -575,20 +795,36 @@ Sets the screen orientation. This API uses a promise to return the result.
| orientation | [Orientation](#orientation) | Yes | Screen orientation.|
**Return value**
+
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
+
**Example**
+
```js
-let promise = screenClass.setOrientation(screen.Orientation.VERTICAL);
-promise.then((data) => {
- console.info('Succeeded in setting Orientation VERTICAL. Data: ' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to set Orientation VERTICAL. Cause: ' + JSON.stringify(err));
-})
+try {
+ let promise = screenClass.setOrientation(screen.Orientation.VERTICAL);
+ promise.then((data) => {
+ console.info('Succeeded in setting the vertical orientation. Data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to set the vertical orientation. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the vertical orientation. Code: ' + JSON.stringify(exception));
+};
```
+
### setScreenActiveMode
+
setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): void
Sets the active mode of the screen. This API uses an asynchronous callback to return the result.
@@ -600,19 +836,33 @@ Sets the active mode of the screen. This API uses an asynchronous callback to re
| modeIndex | number | Yes | Index of the mode to set. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the active mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
+
**Example**
```js
-var modeIndex = 0;
-screenClass.setScreenActiveMode(modeIndex, (err, data) => {
- if (err.code) {
- console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting ScreenActiveMode 0. data: ' + JSON.stringify(data));
-})
+let modeIndex = 0;
+try {
+ screenClass.setScreenActiveMode(modeIndex, (err, data) => {
+ if (err.code) {
+ console.error('Failed to set screen active mode 0. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting screen active mode 0. data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to set screen active mode 0. Code: ' + JSON.stringify(exception));
+};
```
+
### setScreenActiveMode
+
setScreenActiveMode(modeIndex: number): Promise<void>
Sets the active mode of the screen. This API uses a promise to return the result.
@@ -629,18 +879,32 @@ Sets the active mode of the screen. This API uses a promise to return the result
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
+
**Example**
+
```js
-var modeIndex = 0;
-let promise = screenClass.setScreenActiveMode(modeIndex);
-promise.then((data) => {
- console.info('Succeeded in setting ScreenActiveMode 0. Data: ' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err));
-})
+let modeIndex = 0;
+try {
+ let promise = screenClass.setScreenActiveMode(modeIndex);
+ promise.then((data) => {
+ console.info('Succeeded in setting screen active mode 0. Data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to set screen active mode 0. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set screen active mode 0. Code: ' + JSON.stringify(exception));
+};
```
### setDensityDpi
+
setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void;
Sets the pixel density of the screen. This API uses an asynchronous callback to return the result.
@@ -652,19 +916,33 @@ Sets the pixel density of the screen. This API uses an asynchronous callback to
| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the pixel density is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
+
**Example**
+
```js
-var densityDpi = 320;
-screenClass.setDensityDpi(densityDpi, (err, data) => {
- if (err.code) {
- console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeed in setting DensityDpi 320. data: ' + JSON.stringify(data));
-})
+let densityDpi = 320;
+try {
+ screenClass.setDensityDpi(densityDpi, (err, data) => {
+ if (err.code) {
+ console.error('Failed to set the pixel density of the screen to 320. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeed in setting the pixel density of the screen to 320. data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to set the pixel density of the screen to 320. Code: ' + JSON.stringify(exception));
+};
```
### setDensityDpi
+
setDensityDpi(densityDpi: number): Promise<void>
Sets the pixel density of the screen. This API uses a promise to return the result.
@@ -681,18 +959,32 @@ Sets the pixel density of the screen. This API uses a promise to return the resu
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Display Error Codes](../errorcodes/errorcode-display.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1400003 | This display manager service works abnormally. |
+
**Example**
+
```js
-var densityDpi = 320;
-var promise = screenClass.setDensityDpi(densityDpi);
-promise.then((data) => {
- console.info('Succeeded in setting DensityDpi 320. Data: ' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err));
-})
+let densityDpi = 320;
+try {
+ let promise = screenClass.setDensityDpi(densityDpi);
+ promise.then((data) => {
+ console.info('Succeeded in setting the pixel density of the screen to 320. Data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to set the pixel density of the screen to 320. Code: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the pixel density of the screen to 320. Code: ' + JSON.stringify(exception));
+};
```
## Orientation
+
Enumerates the screen orientations.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
@@ -706,6 +998,7 @@ Enumerates the screen orientations.
| REVERSE_HORIZONTAL | 4 | Reverse horizontal. |
## ScreenModeInfo
+
Defines the screen mode information.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md
index 550b62ed355d0a09eb57d17c5473c37cd7e45899..0e8b04295567caf1a018a9f9d3c8122b7f89e41d 100644
--- a/en/application-dev/reference/apis/js-apis-screenshot.md
+++ b/en/application-dev/reference/apis/js-apis-screenshot.md
@@ -73,7 +73,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async
**Example**
```js
- var screenshotOptions = {
+ let screenshotOptions = {
"screenRect": {
"left": 200,
"top": 100,
@@ -85,14 +85,18 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async
"rotation": 0,
"displayId": 0
};
- screenshot.save(screenshotOptions, (err, pixelMap) => {
- if (err) {
- console.log('Failed to save screenshot: ' + JSON.stringify(err));
- return;
- }
- console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
- pixelMap.release(); // Release the memory in time after the PixelMap is used.
- });
+ try {
+ screenshot.save(screenshotOptions, (err, pixelMap) => {
+ if (err) {
+ console.log('Failed to save screenshot. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
+ pixelMap.release(); // Release the memory in time after the PixelMap is used.
+ });
+ } catch (exception) {
+ console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception));
+ };
```
## screenshot.save
@@ -114,14 +118,18 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async
**Example**
```js
- screenshot.save((err, pixelMap) => {
- if (err) {
- console.log('Failed to save screenshot: ' + JSON.stringify(err));
- return;
- }
- console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
- pixelMap.release(); // Release the memory in time after the PixelMap is used.
- });
+ try {
+ screenshot.save((err, pixelMap) => {
+ if (err) {
+ console.log('Failed to save screenshot. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
+ pixelMap.release(); // Release the memory in time after the PixelMap is used.
+ });
+ } catch (exception) {
+ console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception));
+ };
```
## screenshot.save
@@ -149,7 +157,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis
**Example**
```js
- var screenshotOptions = {
+ let screenshotOptions = {
"screenRect": {
"left": 200,
"top": 100,
@@ -161,11 +169,15 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis
"rotation": 0,
"displayId": 0
};
- let promise = screenshot.save(screenshotOptions);
- promise.then((pixelMap) => {
- console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
- pixelMap.release(); // Release the memory in time after the PixelMap is used.
- }).catch((err) => {
- console.log('Failed to save screenshot: ' + JSON.stringify(err));
- });
+ try {
+ let promise = screenshot.save(screenshotOptions);
+ promise.then((pixelMap) => {
+ console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
+ pixelMap.release(); // Release the memory in time after the PixelMap is used.
+ }).catch((err) => {
+ console.log('Failed to save screenshot. Code: ' + JSON.stringify(err));
+ });
+ } catch (exception) {
+ console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception));
+ };
```
diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md
index 91c284004f4b1e2f22d46ba27c3249d9b05dd5bb..e88c24874ded38ec76625957039617147d5664b6 100644
--- a/en/application-dev/reference/apis/js-apis-window.md
+++ b/en/application-dev/reference/apis/js-apis-window.md
@@ -1,6 +1,6 @@
# Window
-The `Window` module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows.
+The **Window** module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows.
This module provides the following common window-related functions:
@@ -44,18 +44,34 @@ Enumerates the window types.
| TYPE_DIALOG9+ | 16 | Modal window.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.|
| TYPE_SCREENSHOT9+ | 17 | Screenshot window.
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API.|
+## Configuration9+
+
+Defines the parameters used for creating a subwindow.
+
+An asynchronous callback is used when a system window is created in the case that [ServiceExtensionContext](js-apis-service-extension-context.md) is used as the context.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+| Name| Type| Mandatory| Description|
+| ---------- | -------------------------- | -- | ----------------------------------- |
+| name | string | Yes| Name of the subwindow. |
+| windowType | [WindowType](#windowtype7) | Yes| Type of the subwindow. |
+| ctx | BaseContext | No| Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-service-extension-context.md).
If this parameter is not set, no context is used. |
+| displayId | number | No| ID of the current physical screen. If this parameter is not set, the default value **-1** is used.|
+| parentId | number | No| ID of the parent window. If this parameter is not set, the default value **-1** is used. |
+
## AvoidAreaType7+
Enumerates the types of the area where the window cannot be displayed.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-| Name | Value | Description |
-|----------------------------------|-----| ----------------- |
-| TYPE_SYSTEM | 0 | Default area of the system.|
-| TYPE_CUTOUT | 1 | Notch. |
-| TYPE_SYSTEM_GESTURE9+ | 2 | Gesture area. |
-| TYPE_KEYBOARD9+ | 3 | Soft keyboard area. |
+| Name | Value | Description |
+| -------------------------------- | ---- | ------------------------------------------------------------ |
+| TYPE_SYSTEM | 0 | Default area of the system. Generally, the status bar, navigation bar, and Dock bar are included. The default area may vary according to the device in use.|
+| TYPE_CUTOUT | 1 | Notch. |
+| TYPE_SYSTEM_GESTURE9+ | 2 | Gesture area. |
+| TYPE_KEYBOARD9+ | 3 | Soft keyboard area. |
## WindowMode7+
@@ -92,14 +108,14 @@ Describes the properties of the status bar and navigation bar.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-| Name | Type| Readable| Writable| Description |
-| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
-| statusBarColor | string | No | Yes | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
-| isStatusBarLightIcon7+ | boolean | No | Yes | Whether any icon on the status bar is highlighted. |
-| statusBarContentColor8+ | string | No | Yes | Color of the text on the status bar. |
-| navigationBarColor | string | No | Yes | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
-| isNavigationBarLightIcon7+ | boolean | No | Yes | Whether any icon on the navigation bar is highlighted. |
-| navigationBarContentColor8+ | string | No | Yes | Color of the text on the navigation bar. |
+| Name | Type| Readable| Writable| Mandatory| Description |
+| -------------------------------------- | -------- | ---- | ---- | ---- | ------------------------------------------------------------ |
+| statusBarColor | string | No | Yes | No | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.|
+| isStatusBarLightIcon7+ | boolean | No | Yes | No | Whether any icon on the status bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.|
+| statusBarContentColor8+ | string | No | Yes | No | Color of the text on the status bar. After this property is set, the setting of **isStatusBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.|
+| navigationBarColor | string | No | Yes | No | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**. The default value is **#0x66000000**.|
+| isNavigationBarLightIcon7+ | boolean | No | Yes | No | Whether any icon on the navigation bar is highlighted. The value **true** means that the icon is highlighted, and **false** means the opposite. The default value is **false**.|
+| navigationBarContentColor8+ | string | No | Yes | No | Color of the text on the navigation bar. After this property is set, the setting of **isNavigationBarLightIcon** is invalid. The default value is **0xE5FFFFFF**.|
## Orientation9+
@@ -147,10 +163,10 @@ Describes the callback for a single system bar.
| Name | Type | Readable| Writable| Description |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
-| type | [WindowType](#windowtype) | Yes | No | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.|
-| isEnable | boolean | Yes | No | Whether the system bar is displayed. |
-| region | [Rect](#rect) | Yes | No | Current position and size of the system bar. |
-| backgroundColor | string | Yes | No | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
+| type | [WindowType](#windowtype7) | Yes | No | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.|
+| isEnable | boolean | Yes | No | Whether the system bar is displayed. The value **true** means that the system bar is displayed, and **false** means the opposite.|
+| region | [Rect](#rect7) | Yes | No | Current position and size of the system bar. |
+| backgroundColor | string | Yes | No | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
| contentColor | string | Yes | No | Color of the text on the system bar. |
## SystemBarTintState8+
@@ -187,11 +203,11 @@ Describes the area where the window cannot be displayed.
| Name | Type | Readable| Writable| Description |
| ---------- | ------------- | ---- | ---- | ------------------ |
-| visible9+ | boolean | Yes | Yes | Whether the window can be displayed in the area.|
-| leftRect | [Rect](#rect) | Yes | Yes | Rectangle on the left of the screen.|
-| topRect | [Rect](#rect) | Yes | Yes | Rectangle at the top of the screen.|
-| rightRect | [Rect](#rect) | Yes | Yes | Rectangle on the right of the screen.|
-| bottomRect | [Rect](#rect) | Yes | Yes | Rectangle at the bottom of the screen.|
+| visible9+ | boolean | Yes | Yes | Whether the window can be displayed in the area. The value **true** means that the window can be displayed in the area, and **false** means the opposite.|
+| leftRect | [Rect](#rect7) | Yes | Yes | Rectangle on the left of the screen.|
+| topRect | [Rect](#rect7) | Yes | Yes | Rectangle at the top of the screen.|
+| rightRect | [Rect](#rect7) | Yes | Yes | Rectangle on the right of the screen.|
+| bottomRect | [Rect](#rect7) | Yes | Yes | Rectangle at the bottom of the screen.|
## Size7+
@@ -212,30 +228,30 @@ Describes the window properties.
| Name | Type | Readable| Writable| Description |
| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
-| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. |
-| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. |
-| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is `false`. |
-| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`. |
-| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is `true`. |
-| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is `true`. |
-| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. |
-| dimBehindValue(deprecated) | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.
**NOTE**
This property is supported since API version 7 and deprecated since API version 9.
|
-| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is `false`. |
-| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is `false`. |
-| isRoundCorner(deprecated) | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`.
**NOTE**
This property is supported since API version 7 and deprecated since API version 9.
|
-| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is `false`. |
-| id9+ | number | Yes | No | Window ID. The default value is `0.0`. |
+| windowRect7+ | [Rect](#rect7) | Yes | Yes | Window size. |
+| type7+ | [WindowType](#windowtype7) | Yes | Yes | Window type. |
+| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. The value **true** means that the window is displayed in full screen mode, and **false** means the opposite.|
+| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. The value **true** means that the window is immersive, and **false** means the opposite.|
+| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. The value **true** means that the window can gain focus, and **false** means the opposite.|
+| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is **true**. The value **true** means that the window is touchable, and **false** means the opposite.|
+| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness. |
+| dimBehindValue(deprecated) | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value **1** indicates the maximum dimness.
**NOTE**
This property is supported since API version 7 and deprecated since API version 9.
|
+| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**. The value **true** means that the screen is always on, and **false** means the opposite.|
+| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**. The value **true** means that the window is in privacy mode, and **false** means the opposite.|
+| isRoundCorner(deprecated) | boolean | Yes | Yes | Whether the window has rounded corners. The default value is **false**. The value **true** means that the window has rounded corners, and **false** means the opposite.
**NOTE**
This property is supported since API version 7 and deprecated since API version 9.
|
+| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**. The value **true** means that the window is transparent, and **false** means the opposite.|
+| id9+ | number | Yes | No | Window ID. The default value is **0.0**. |
## ColorSpace8+
-Describes the color gamut mode.
+Enumerates the color spaces.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description |
| ---------- | ------ | -------------- |
-| DEFAULT | 0 | Default color gamut mode.|
-| WIDE_GAMUT | 1 | Wide color gamut mode. |
+| DEFAULT | 0 | Default gamut.|
+| WIDE_GAMUT | 1 | Wide-gamut. |
## ScaleOptions9+
@@ -247,10 +263,10 @@ Describes the scale parameters.
| Name | Type| Readable| Writable| Description |
| ------ | -------- | ---- | ---- | -------------------------------------------------- |
-| x | number | No | Yes | Scale factor along the x-axis. The default value is `1.0`. |
-| y | number | No | Yes | Scale factor along the y-axis. The default value is `1.0`. |
-| pivotX | number | No | Yes | X coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|
-| pivotY | number | No | Yes | Y coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|
+| x | number | No | Yes | Scale factor along the x-axis. The default value is **1.0**. |
+| y | number | No | Yes | Scale factor along the y-axis. The default value is **1.0**. |
+| pivotX | number | No | Yes | X coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is **0.5**.|
+| pivotY | number | No | Yes | Y coordinate of the scale center. The value ranges from 0.0 to 1.0, and the default value is **0.5**.|
## RotateOptions9+
@@ -262,11 +278,11 @@ Describes the rotation parameters.
| Name | Type| Readable| Writable| Description |
| ------ | -------- | ---- | ---- | -------------------------------------------------- |
-| x | number | No | Yes | Rotation angle around the x-axis. The default value is `0.0`. |
-| y | number | No | Yes | Rotation angle around the y-axis. The default value is `0.0`. |
-| z | number | No | Yes | Rotation angle around the z-xis. The default value is `0.0`. |
-| pivotX | number | No | Yes | X coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|
-| pivotY | number | No | Yes | Y coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is `0.5`.|
+| x | number | No | Yes | Rotation angle around the x-axis. The default value is **0.0**. |
+| y | number | No | Yes | Rotation angle around the y-axis. The default value is **0.0**. |
+| z | number | No | Yes | Rotation angle around the z-xis. The default value is **0.0**. |
+| pivotX | number | No | Yes | X coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is **0.5**.|
+| pivotY | number | No | Yes | Y coordinate of the rotation center. The value ranges from 0.0 to 1.0, and the default value is **0.5**.|
## TranslateOptions9+
@@ -278,179 +294,106 @@ Describes the translation parameters.
| Name| Type| Readable| Writable| Description |
| ---- | -------- | ---- | ---- | ---------------------------- |
-| x | number | No | Yes | Distance to translate along the x-axis. The default value is `0.0`.|
-| y | number | No | Yes | Distance to translate along the y-axis. The default value is `0.0`.|
-| z | number | No | Yes | Distance to translate along the z-axis. The default value is `0.0`.|
+| x | number | No | Yes | Distance to translate along the x-axis. The default value is **0.0**.|
+| y | number | No | Yes | Distance to translate along the y-axis. The default value is **0.0**.|
+| z | number | No | Yes | Distance to translate along the z-axis. The default value is **0.0**.|
-## window.create7+
+## window.createWindow9+
-create(id: string, type: WindowType, callback: AsyncCallback<Window>): void
+createWindow(config: Configuration, callback: AsyncCallback<Window>): void
Creates a subwindow. This API uses an asynchronous callback to return the result.
-**Model restriction**: This API can be used only in the FA model.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | ------------------------------------ |
-| id | string | Yes | Window ID. |
-| type | [WindowType](#windowtype) | Yes | Window type. |
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.|
-
-**Example**
-
-```js
-let windowClass = null;
-window.create('first', window.WindowType.TYPE_APP,(err,data) => {
- if(err.code){
- console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
-});
-```
-
-## window.create7+
-
-create(id: string, type: WindowType): Promise<Window>
-
-Creates a subwindow. This API uses a promise to return the result.
-
-**Model restriction**: This API can be used only in the FA model.
-
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------------------------- | ---- | ---------- |
-| id | string | Yes | Window ID. |
-| type | [WindowType](#windowtype) | Yes | Window type.|
-
-**Return value**
-
-| Type | Description |
-| -------------------------------- | --------------------------------------- |
-| Promise<[Window](#window)> | Promise used to return the subwindow created.|
-
-**Example**
-
-```js
-let windowClass = null;
-let promise = window.create('first', window.WindowType.TYPE_APP);
-promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
-});
-```
-
-## window.create8+
-
-create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void
-
-Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses an asynchronous callback to return the result.
+| Name| Type| Mandatory| Description|
+| -------- | -------------------------------------- | -- | --------------------------------- |
+| config | [Configuration](#configuration9) | Yes| Current application context. |
+| callback | AsyncCallback<[Window](#window)> | Yes| Callback used to return the subwindow created.|
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Error codes**
-**Parameters**
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
-| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
-| id | string | Yes | Window ID. |
-| type | [WindowType](#windowtype) | Yes | Window type. |
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created. |
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 1300001 | Repeated operation. |
+| 1300006 | This window context is abnormal. |
**Example**
```js
let windowClass = null;
- window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
- if (err.code) {
- console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
- windowClass.resetSize(500, 1000);
-});
+let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context};
+try {
+ window.createWindow(config, (err, data) => {
+ if (err.code) {
+ console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ windowClass = data;
+ console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
+ windowClass.resetSize(500, 1000);
+ });
+} catch (exception) {
+ console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
+};
```
-## window.create8+
+## window.createWindow9+
-create(ctx: Context, id: string, type: WindowType): Promise<Window>
+createWindow(config: Configuration): Promise<Window>
-Creates a subwindow (in API version 8) or a system window (from API version 9). This API uses a promise to return the result.
+Creates a subwindow. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
-| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
-| id | string | Yes | Window ID. |
-| type | [WindowType](#windowtype) | Yes | Window type. |
+| Name| Type| Mandatory| Description|
+| ------ | -------------------------------- | -- | ------------------ |
+| config | [Configuration](#configuration9) | Yes| Current application context.|
**Return value**
-| Type | Description |
-| -------------------------------- | --------------------------------------- |
+| Type| Description|
+| -------------------------------- | ------------------------------------ |
| Promise<[Window](#window)> | Promise used to return the subwindow created.|
-**Example**
-
-```js
-let windowClass = null;
-let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT);
-promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
-});
-```
-
-## window.find7+
-
-find(id: string, callback: AsyncCallback<Window>): void
-
-Finds a window based on the ID. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Error codes**
-**Parameters**
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | ------------------------------------ |
-| id | string | Yes | Window ID. |
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.|
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 1300001 | Repeated operation. |
+| 1300006 | This window context is abnormal. |
**Example**
```js
let windowClass = null;
- window.find('alertWindow', (err, data) => {
- if (err.code) {
- console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
-});
+let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context};
+try {
+ let promise = window.createWindow(config);
+ promise.then((data)=> {
+ windowClass = data;
+ console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
+};
```
-## window.find7+
+## window.findWindow9+
-find(id: string): Promise<Window>
+findWindow(name: string): Window
-Finds a window based on the ID. This API uses a promise to return the result.
+Finds a window based on the ID.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
@@ -458,118 +401,69 @@ Finds a window based on the ID. This API uses a promise to return the result.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
-| id | string | Yes | Window ID.|
+| name | string | Yes | Window ID.|
**Return value**
-| Type | Description |
-| -------------------------------- | ------------------------------------- |
-| Promise<[Window](#window)> | Promise used to return the window found.|
+| Type| Description|
+| ----------------- | ------------------- |
+| [Window](#window) | Window found.|
**Example**
```js
-let windowClass = null;
-let promise = window.find('alertWindow');
-promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
-});
+try {
+ let windowClass = window.findWindow('alertWindow');
+} catch (exception) {
+ console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
+};
```
-## window.getTopWindow
+## window.getLastWindow9+
-getTopWindow(callback: AsyncCallback<Window>): void
+getLastWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void
Obtains the top window of the current application. This API uses an asynchronous callback to return the result.
-**Model restriction**: This API can be used only in the FA model.
-
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | -------------------------------------------- |
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.|
-
-**Example**
-
-```js
-let windowClass = null;
-window.getTopWindow((err, data) => {
- if (err.code) {
- console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
-});
-```
-
-## window.getTopWindow
-
-getTopWindow(): Promise<Window>
-
-Obtains the top window of the current application. This API uses a promise to return the result.
-
-**Model restriction**: This API can be used only in the FA model.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Return value**
-
-| Type | Description |
-| -------------------------------- | ----------------------------------------------- |
-| Promise<[Window](#window)> | Promise used to return the top window obtained.|
-
-**Example**
-
-```js
-let windowClass = null;
-let promise = window.getTopWindow();
-promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
-})
-```
+| Name| Type| Mandatory| Description|
+| -------- | -------------------------------------- | -- | ---------------------------------------- |
+| ctx | BaseContext | Yes| Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-ability-context.md).|
+| callback | AsyncCallback<[Window](#window)> | Yes| Callback used to return the top window obtained.|
-## window.getTopWindow8+
+**Error codes**
-getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
-Obtains the top window of the current application. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
-| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).|
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. |
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300006 | This window context is abnormal. |
**Example**
```js
let windowClass = null;
-window.getTopWindow(this.context, (err, data) => {
- if (err.code) {
- console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
-});
+try {
+ window.getLastWindow(this.context, (err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ windowClass = data;
+ console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
+};
```
-## window.getTopWindow8+
+## window.getLastWindow9+
-getTopWindow(ctx: Context): Promise<Window>
+getLastWindow(ctx: BaseContext): Promise<Window>
Obtains the top window of the current application. This API uses a promise to return the result.
@@ -577,27 +471,40 @@ Obtains the top window of the current application. This API uses a promise to re
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------- | ---- | ------------------------------------------------------------ |
-| ctx | Context | Yes | Current application context.
For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).
For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).|
+| Name| Type| Mandatory| Description|
+| ------ | ----------- | ---- | ------------------------------------------------------------ |
+| ctx | BaseContext | Yes | Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-ability-context.md).|
**Return value**
-| Type | Description |
-| -------------------------------- | ----------------------------------------------- |
+| Type| Description|
+| -------------------------------- | ------------------------------------------- |
| Promise<[Window](#window)> | Promise used to return the top window obtained.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300006 | This window context is abnormal. |
+
**Example**
```js
let windowClass = null;
-let promise = window.getTopWindow(this.context);
-promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
-})
+try {
+ let promise = window.getLastWindow(this.context);
+ promise.then((data)=> {
+ windowClass = data;
+ console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
+};
```
## window.minimizeAll9+
@@ -616,26 +523,38 @@ Minimizes all windows on a display. This API uses an asynchronous callback to re
| id | number | Yes | ID of the [display](js-apis-display.md#display).|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
import display from '@ohos.display'
import window from '@ohos.window'
-let displayClass = null;
-display.getDefaultDisplay((err, data) => {
- if(err.code) {
- return;
- }
- displayClass = data;
- window.minimizeAll(displayClass.id, (err, data) => {
+try {
+ displayClass = display.getDefaultDisplaySync();
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
+ return;
+};
+
+try {
+ window.minimizeAll(displayClass.id, (err) => {
if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in minimizing all windows.');
});
-});
+} catch (exception) {
+ console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
+};
```
## window.minimizeAll9+
@@ -659,6 +578,14 @@ Minimizes all windows on a display. This API uses a promise to return the result
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
@@ -666,18 +593,23 @@ import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
-display.getDefaultDisplay((err, data) => {
- if(err.code) {
- return;
- }
- displayClass = data;
+try {
+ displayClass = display.getDefaultDisplaySync();
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
+ return;
+};
+
+try {
let promise = window.minimizeAll(displayClass.id);
- promise.then((data)=> {
+ promise.then(()=> {
console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
- })
-});
+ });
+} catch (exception) {
+ console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
+};
```
## window.toggleShownStateForAllAppWindows9+
@@ -695,10 +627,18 @@ Hides or restores the application's windows during quick multi-window switching.
| -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
-window.toggleShownStateForAllAppWindows((err, data) => {
+window.toggleShownStateForAllAppWindows((err) => {
if (err.code) {
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
return;
@@ -722,12 +662,20 @@ Hides or restores the application's windows during quick multi-window switching.
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
let promise = window.toggleShownStateForAllAppWindows();
-promise.then((data)=> {
- console.info('Succeeded in toggling shown state for all app windows. Data: ' + JSON.stringify(data));
+promise.then(()=> {
+ console.info('Succeeded in toggling shown state for all app windows.');
}).catch((err)=>{
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
})
@@ -749,12 +697,28 @@ Sets the window layout mode. This API uses an asynchronous callback to return th
| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-**Example**
+**Error codes**
-```js
-window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => {
- console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
-});
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+try {
+ window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err) => {
+ if(err.code) {
+ console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting window layout mode.');
+ });
+} catch (exception) {
+ console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
+};
```
## window.setWindowLayoutMode9+
@@ -778,18 +742,30 @@ Sets the window layout mode. This API uses a promise to return the result.
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
-let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
-promise.then((data)=> {
- console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
-})
+try {
+ let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
+ promise.then(()=> {
+ console.info('Succeeded in setting window layout mode.');
+ }).catch((err)=>{
+ console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
+};
```
-## on('systemBarTintChange')8+
+## window.on('systemBarTintChange')8+
on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void
@@ -803,18 +779,22 @@ Enables listening for properties changes of the status bar and navigation bar.
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
+| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.|
| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the properties of the status bar and navigation bar. |
**Example**
```js
-window.on('systemBarTintChange', (data) => {
- console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
-});
+try {
+ window.on('systemBarTintChange', (data) => {
+ console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
+};
```
-## off('systemBarTintChange')8+
+## window.off('systemBarTintChange')8+
off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void
@@ -828,331 +808,432 @@ Disables listening for properties changes of the status bar and navigation bar.
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
+| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.|
| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the properties of the status bar and navigation bar. |
**Example**
```js
-window.off('systemBarTintChange');
+try {
+ window.off('systemBarTintChange');
+} catch (exception) {
+ console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
+};
```
-## Window
-
-Represents the current window instance, which is the basic unit managed by the window manager.
-
-In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a `Window` instance and then call a method in this instance.
+## window.create(deprecated)
-### hide7+
+create(id: string, type: WindowType, callback: AsyncCallback<Window>): void
-hide (callback: AsyncCallback<void>): void
+Creates a subwindow. This API uses an asynchronous callback to return the result.
-Hides this window. This API uses an asynchronous callback to return the result.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9) instead.
-**System API**: This is a system API.
+**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ---------- |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | ------------------------------------ |
+| id | string | Yes | Window ID. |
+| type | [WindowType](#windowtype7) | Yes | Window type. |
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.|
**Example**
```js
-windowClass.hide((err, data) => {
- if (err.code) {
- console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
+let windowClass = null;
+window.create('first', window.WindowType.TYPE_APP,(err,data) => {
+ if(err.code){
+ console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data));
-})
+ windowClass = data;
+ console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
+});
```
-### hide7+
+## window.create(deprecated)
-hide(): Promise<void>
+create(id: string, type: WindowType): Promise<Window>
-Hides this window. This API uses a promise to return the result.
+Creates a subwindow. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9-1) instead.
+
+**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------- | ---- | ---------- |
+| id | string | Yes | Window ID. |
+| type | [WindowType](#windowtype7) | Yes | Window type.|
+
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| -------------------------------- | --------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the subwindow created.|
**Example**
```js
-let promise = windowClass.hide();
+let windowClass = null;
+let promise = window.create('first', window.WindowType.TYPE_APP);
promise.then((data)=> {
- console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data));
+ windowClass = data;
+ console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
-})
+ console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
+});
```
-### hideWithAnimation9+
+## window.create(deprecated)
-hideWithAnimation(callback: AsyncCallback<void>): void
+create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback<Window>): void
-Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result.
+Creates a subwindow in the FA model
-**System API**: This is a system API.
+or a system window in the stage model. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ---------- |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
+| ctx | BaseContext | Yes | Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-service-extension-context.md).|
+| id | string | Yes | Window ID. |
+| type | [WindowType](#windowtype7) | Yes | Window type. |
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created. |
**Example**
```js
-windowClass.hideWithAnimation((err, data) => {
+let windowClass = null;
+window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err.code) {
- console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
+ console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data));
-})
+ windowClass = data;
+ console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
+ windowClass.resetSize(500, 1000);
+});
```
-### hideWithAnimation9+
+## window.create(deprecated)
-hideWithAnimation(): Promise<void>
+create(ctx: BaseContext, id: string, type: WindowType): Promise<Window>
-Hides this window and plays an animation during the process. This API uses a promise to return the result.
+Creates a subwindow in the FA model
-**System API**: This is a system API.
+or a system window in the stage model. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createWindow()](#windowcreatewindow9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
+| ctx | BaseContext | Yes | Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-service-extension-context.md).|
+| id | string | Yes | Window ID. |
+| type | [WindowType](#windowtype7) | Yes | Window type. |
+
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| -------------------------------- | --------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the subwindow created.|
**Example**
```js
-let promise = windowClass.hideWithAnimation();
+let windowClass = null;
+let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> {
- console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
+ windowClass = data;
+ console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
-})
+ console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
+});
```
-### show7+
+## window.find(deprecated)
-show(callback: AsyncCallback<void>): void
+find(id: string, callback: AsyncCallback<Window>): void
-Shows this window. This API uses an asynchronous callback to return the result.
+Finds a window based on the ID. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [findWindow()](#windowfindwindow9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ---------- |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | ------------------------------------ |
+| id | string | Yes | Window ID. |
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.|
**Example**
```js
-windowClass.show((err, data) => {
+let windowClass = null;
+window.find('alertWindow', (err, data) => {
if (err.code) {
- console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
+ console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
-})
+ windowClass = data;
+ console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
+});
```
-### show7+
+## window.find(deprecated)
-show(): Promise<void>
+find(id: string): Promise<Window>
-Shows this window. This API uses a promise to return the result.
+Finds a window based on the ID. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [findWindow()](#windowfindwindow9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------- |
+| id | string | Yes | Window ID.|
+
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| -------------------------------- | ------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the window found.|
**Example**
```js
-let promise = windowClass.show();
+let windowClass = null;
+let promise = window.find('alertWindow');
promise.then((data)=> {
- console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
+ windowClass = data;
+ console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
-})
+ console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
+});
```
-### showWithAnimation9+
+## window.getTopWindow(deprecated)
-showWithAnimation(callback: AsyncCallback<void>): void
+getTopWindow(callback: AsyncCallback<Window>): void
-Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result.
+Obtains the top window of the current application. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9) instead.
+
+**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ---------- |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | -------------------------------------------- |
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.|
**Example**
```js
-windowClass.showWithAnimation((err, data) => {
+let windowClass = null;
+window.getTopWindow((err, data) => {
if (err.code) {
- console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
-})
+ windowClass = data;
+ console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
+});
```
-### showWithAnimation9+
+## window.getTopWindow(deprecated)
-showWithAnimation(): Promise<void>
+getTopWindow(): Promise<Window>
-Shows this window and plays an animation during the process. This API uses a promise to return the result.
+Obtains the top window of the current application. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9-1) instead.
+
+**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| -------------------------------- | ----------------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the top window obtained.|
**Example**
```js
-let promise = windowClass.showWithAnimation();
+let windowClass = null;
+let promise = window.getTopWindow();
promise.then((data)=> {
- console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
+ windowClass = data;
+ console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
```
-### destroy7+
+## window.getTopWindow(deprecated)
-destroy(callback: AsyncCallback<void>): void
+getTopWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void
-Destroys this window. This API uses an asynchronous callback to return the result.
+Obtains the top window of the current application. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ---------- |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
+| ctx | BaseContext | Yes | Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-ability-context.md).|
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. |
**Example**
```js
-windowClass.destroy((err, data) => {
+let windowClass = null;
+window.getTopWindow(this.context, (err, data) => {
if (err.code) {
- console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
-})
+ windowClass = data;
+ console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
+});
```
-### destroy7+
+## window.getTopWindow(deprecated)
-destroy(): Promise<void>
+getTopWindow(ctx: BaseContext): Promise<Window>
-Destroys this window. This API uses a promise to return the result.
+Obtains the top window of the current application. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getLastWindow()](#windowgetlastwindow9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------- | ---- | ------------------------------------------------------------ |
+| ctx | BaseContext | Yes | Current application context.
For details about the context in the FA model, see [Context](js-apis-Context.md).
For details about the context in the stage model, see [Context](js-apis-ability-context.md).|
+
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| -------------------------------- | ----------------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the top window obtained.|
**Example**
```js
-let promise = windowClass.destroy();
+let windowClass = null;
+let promise = window.getTopWindow(this.context);
promise.then((data)=> {
- console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
+ windowClass = data;
+ console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
```
-### moveTo7+
+## Window
-moveTo(x: number, y: number, callback: AsyncCallback<void>): void
+Represents the current window instance, which is the basic unit managed by the window manager.
-Moves this window. This API uses an asynchronous callback to return the result.
+In the following API examples, you must use [getLastWindow()](#windowgetlastwindow9), [createWindow()](#windowcreatewindow9), or [findWindow()](#windowfindwindow9) to obtain a **Window** instance and then call a method in this instance.
+
+### hide7+
+
+hide (callback: AsyncCallback<void>): void
+
+Hides this window. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ------------------------------------------------- |
-| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
-| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
**Example**
```js
-windowClass.moveTo(300, 300, (err, data)=>{
+windowClass.hide((err) => {
if (err.code) {
- console.error('Failed to move the window. Cause:' + JSON.stringify(err));
+ console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
-
-});
+ console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data));
+})
```
-### moveTo7+
-
-moveTo(x: number, y: number): Promise<void>
+### hide7+
-Moves this window. This API uses a promise to return the result.
+hide(): Promise<void>
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+Hides this window. This API uses a promise to return the result.
-**Parameters**
+**System API**: This is a system API.
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------- |
-| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
-| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
@@ -1160,59 +1241,72 @@ Moves this window. This API uses a promise to return the result.
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
**Example**
```js
-let promise = windowClass.moveTo(300, 300);
-promise.then((data)=> {
- console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
+let promise = windowClass.hide();
+promise.then(()=> {
+ console.info('Succeeded in hiding the window.');
}).catch((err)=>{
- console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
+ console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
```
-### resetSize7+
+### hideWithAnimation9+
-resetSize(width: number, height: number, callback: AsyncCallback<void>): void
+hideWithAnimation(callback: AsyncCallback<void>): void
-Changes the size of this window. This API uses an asynchronous callback to return the result.
+Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | -------------------------- |
-| width | number | Yes | New width of the window, in px.|
-| height | number | Yes | New height of the window, in px.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+| 1300004 | Unauthorized operation. |
**Example**
```js
-windowClass.resetSize(500, 1000, (err, data) => {
+windowClass.hideWithAnimation((err) => {
if (err.code) {
- console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
+ console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
-});
+ console.info('Succeeded in hiding the window with animation.');
+})
```
-### resetSize7+
-
-resetSize(width: number, height: number): Promise<void>
+### hideWithAnimation9+
-Changes the size of this window. This API uses a promise to return the result.
+hideWithAnimation(): Promise<void>
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+Hides this window and plays an animation during the process. This API uses a promise to return the result.
-**Parameters**
+**System API**: This is a system API.
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | -------------------------- |
-| width | number | Yes | New width of the window, in px.|
-| height | number | Yes | New height of the window, in px.|
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
@@ -1220,323 +1314,660 @@ Changes the size of this window. This API uses a promise to return the result.
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+| 1300004 | Unauthorized operation. |
+
**Example**
```js
-let promise = windowClass.resetSize(500, 1000);
-promise.then((data)=> {
- console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
+let promise = windowClass.hideWithAnimation();
+promise.then(()=> {
+ console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
-});
+ console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
+})
```
-### setWindowType(deprecated)
-
-setWindowType(type: WindowType, callback: AsyncCallback<void>): void
-
-Sets the type of this window. This API uses an asynchronous callback to return the result.
+### showWindow9+
-**System API**: This is a system API.
+showWindow(callback: AsyncCallback<void>): void
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9.
+Shows this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ---------- |
-| type | [WindowType](#windowtype) | Yes | Window type.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | ------------------------- | -- | --------- |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
**Example**
```js
-let type = window.WindowType.TYPE_APP;
-windowClass.setWindowType(type, (err, data) => {
- if (err.code) {
- console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
+windowClass.showWindow((err) => {
+ if (err.code) {
+ console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in showing the window.');
});
```
-### setWindowType(deprecated)
-
-setWindowType(type: WindowType): Promise<void>
-
-Sets the type of this window. This API uses a promise to return the result.
+### showWindow9+
-**System API**: This is a system API.
+showWindow(): Promise<void>
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9.
+Shows this window. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-**Parameters**
-
-| Name| Type | Mandatory| Description |
-| ------ | ------------------------- | ---- | ---------- |
-| type | [WindowType](#windowtype) | Yes | Window type.|
-
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
+| Type| Description|
+| ------------------- | ----------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
**Example**
```js
-let type = window.WindowType.TYPE_APP;
-let promise = windowClass.setWindowType(type);
-promise.then((data)=> {
- console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
+let promise = windowClass.showWindow();
+promise.then(()=> {
+ console.info('Succeeded in showing the window.');
}).catch((err)=>{
- console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
+ console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
});
```
-### getProperties
+### showWithAnimation9+
-getProperties(callback: AsyncCallback<WindowProperties>): void
+showWithAnimation(callback: AsyncCallback<void>): void
-Obtains the properties of this window. This API uses an asynchronous callback to return the result.
+Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
-| callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | ---------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+| 1300004 | Unauthorized operation. |
**Example**
```js
-windowClass.getProperties((err, data) => {
+windowClass.showWithAnimation((err) => {
if (err.code) {
- console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
+ console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
-});
+ console.info('Succeeded in showing the window with animation.');
+})
```
-### getProperties
+### showWithAnimation9+
+
+showWithAnimation(): Promise<void>
-getProperties(): Promise<WindowProperties>
+Shows this window and plays an animation during the process. This API uses a promise to return the result.
-Obtains the properties of this window. This API uses a promise to return the result.
+**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
-| Type | Description |
-| ---------------------------------------------------- | ------------------------------- |
-| Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.|
+| Type | Description |
+| ------------------- | ------------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+| 1300004 | Unauthorized operation. |
**Example**
```js
-let promise = windowClass.getProperties();
-promise.then((data)=> {
- console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
+let promise = windowClass.showWithAnimation();
+promise.then(()=> {
+ console.info('Succeeded in showing the window with animation.');
}).catch((err)=>{
- console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
-});
+ console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
+})
```
-### getAvoidArea7+
+### destroyWindow9+
-getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void
+destroyWindow(callback: AsyncCallback<void>): void
-Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses an asynchronous callback to return the result.
+Destroys this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ |
-| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. `TYPE_SYSTEM_GESTURE` indicates the gesture area. `TYPE_KEYBOARD` indicates the soft keyboard area.|
-| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. |
+| Name| Type| Mandatory| Description|
+| -------- | ------------------------- | -- | --------- |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
**Example**
```js
-let type = window.AvoidAreaType.TYPE_SYSTEM;
-windowClass.getAvoidArea(type, (err, data) => {
+windowClass.destroyWindow((err) => {
if (err.code) {
- console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
+ console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
-});
+ console.info('Succeeded in destroying the window.');
+})
```
-### getAvoidArea7+
+### destroyWindow9+
-getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)>
+destroyWindow(): Promise<void>
-Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses a promise to return the result.
+Destroys this window. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-**Parameters**
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
-| Name| Type | Mandatory| Description |
-| ------ |----------------------------------| ---- | ------------------------------------------------------------ |
-| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. `TYPE_SYSTEM_GESTURE` indicates the gesture area. `TYPE_KEYBOARD` indicates the soft keyboard area.|
+**Error codes**
-**Return value**
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
-| Type | Description |
-|-----------------------------------------| ----------------------------------- |
-| Promise<[AvoidArea](#avoidarea7)> | Promise used to return the area.|
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
**Example**
```js
-let type = window.AvoidAreaType.TYPE_SYSTEM;
-let promise = windowClass.getAvoidArea(type);
-promise.then((data)=> {
- console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
+let promise = windowClass.destroyWindow();
+promise.then(()=> {
+ console.info('Succeeded in destroying the window.');
}).catch((err)=>{
- console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
-});
+ console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
+})
```
-### setFullScreen
+### moveWindowTo9+
-setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void
+moveWindowTo(x: number, y: number, callback: AsyncCallback<void>): void
-Sets whether to enable the full-screen mode for this window. This API uses an asynchronous callback to return the result.
+Moves this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------ | ------------------------- | ---- | ---------------------------------------------- |
-| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name| Type| Mandatory| Description|
+| -------- | ------------------------- | -- | --------------------------------------------- |
+| x | number | Yes| Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
+| y | number | Yes| Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
**Example**
```js
-let isFullScreen = true;
-windowClass.setFullScreen(isFullScreen, (err, data) => {
- if (err.code) {
- console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.moveWindowTo(300, 300, (err)=>{
+ if (err.code) {
+ console.error('Failed to move the window. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in moving the window.');
+ });
+} catch (exception) {
+ console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
+};
```
-### setFullScreen
+### moveWindowTo9+
-setFullScreen(isFullScreen: boolean): Promise<void>
+moveWindowTo(x: number, y: number): Promise<void>
-Sets whether to enable the full-screen mode for this window. This API uses a promise to return the result.
+Moves this window. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------ | ------- | ---- | ---------------------------------------------- |
-| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
+| Name| Type| Mandatory| Description|
+| -- | ----- | -- | --------------------------------------------- |
+| x | number | Yes| Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
+| y | number | Yes| Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
+| Type| Description|
+| ------------------- | ------------------------ |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
-let isFullScreen = true;
-let promise = windowClass.setFullScreen(isFullScreen);
-promise.then((data)=> {
- console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
-});
+try {
+ let promise = windowClass.moveWindowTo(300, 300);
+ promise.then(()=> {
+ console.info('Succeeded in moving the window.');
+ }).catch((err)=>{
+ console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
+};
```
-### setLayoutFullScreen7+
+### resize9+
-setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void
+resize(width: number, height: number, callback: AsyncCallback<void>): void
-Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result.
+Changes the size of this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
-| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name| Type| Mandatory| Description|
+| -------- | ------------------------- | -- | ------------------------ |
+| width | number | Yes| New width of the window, in px.|
+| height | number | Yes| New height of the window, in px.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
-**Example**
+**Error codes**
-```js
-let isLayoutFullScreen= true;
-windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
- if (err.code) {
- console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
-});
-```
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
-### setLayoutFullScreen7+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
-setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>
+**Example**
-Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result.
+```js
+try {
+ windowClass.resize(500, 1000, (err) => {
+ if (err.code) {
+ console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in changing the window size.');
+ });
+} catch (exception) {
+ console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
+};
+```
+
+### resize9+
+
+resize(width: number, height: number): Promise<void>
+
+Changes the size of this window. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------------ | ------- | ---- | ------------------------------------------------------------ |
-| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
+| Name| Type| Mandatory| Description|
+| ------ | ------ | -- | ------------------------ |
+| width | number | Yes| New width of the window, in px.|
+| height | number | Yes| New height of the window, in px.|
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+try {
+ let promise = windowClass.resize(500, 1000);
+ promise.then(()=> {
+ console.info('Succeeded in changing the window size.');
+ }).catch((err)=>{
+ console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowMode9+
+
+setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void
+
+Sets the mode of this window. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------------------------- | -- | --------- |
+| mode | [WindowMode](#windowmode7) | Yes| Window mode to set.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let mode = window.WindowMode.FULLSCREEN;
+try {
+ windowClass.setWindowMode(mode, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window mode.');
+ });
+} catch (exception) {
+ console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowMode9+
+
+setWindowMode(mode: WindowMode): Promise<void>
+
+Sets the type of this window. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------------------------- | -- | --------- |
+| mode | [WindowMode](#windowmode7) | Yes| Window mode to set.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ----------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let mode = window.WindowMode.FULLSCREEN;
+try {
+ let promise = windowClass.setWindowMode(type);
+ promise.then(()=> {
+ console.info('Succeeded in setting the window mode.');
+ }).catch((err)=>{
+ console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### getWindowProperties9+
+
+getWindowProperties(): WindowProperties
+
+Obtains the properties of this window.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type| Description|
+| ------------------------------------- | ------------- |
+| [WindowProperties](#windowproperties) | Window properties obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+try {
+ let properties = windowClass.getWindowProperties();
+} catch (exception) {
+ console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### getWindowAvoidArea9+
+
+getWindowAvoidArea(type: AvoidAreaType): AvoidArea
+
+Obtains the area where this window cannot be displayed, for example, the system bar area, notch, gesture area, and soft keyboard area.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ---- |----------------------------------| -- | ------------------------------------------------------------ |
+| type | [AvoidAreaType](#avoidareatype7) | Yes| Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area.|
+
+**Return value**
+
+| Type| Description|
+|--------------------------| ----------------- |
+| [AvoidArea](#avoidarea7) | Area where the window cannot be displayed.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let type = window.AvoidAreaType.TYPE_SYSTEM;
+try {
+ let avoidArea = windowClass.getWindowAvoidArea(type);
+} catch (exception) {
+ console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowLayoutFullScreen9+
+
+setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void
+
+Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ------------------ | ------------------------- | -- | --------- |
+| isLayoutFullScreen | boolean | Yes| Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isLayoutFullScreen= true;
+try {
+ windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window layout to full-screen mode.');
+ });
+} catch (exception) {
+ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowLayoutFullScreen9+
+
+setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>
+
+Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ------------------ | ------- | -- | ------------------------------------------------------------------------------------------------ |
+| isLayoutFullScreen | boolean | Yes| Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
let isLayoutFullScreen = true;
-let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
-promise.then((data)=> {
- console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
-});
+try {
+ let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
+ promise.then(()=> {
+ console.info('Succeeded in setting the window layout to full-screen mode.');
+ }).catch((err)=>{
+ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
+};
```
-### setSystemBarEnable7+
+### setWindowSystemBarEnable9+
-setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void
+setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void
Sets whether to display the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.
@@ -1544,28 +1975,41 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
-| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `['status', 'navigation']`. By default, they are not displayed.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name| Type| Mandatory| Description|
+| -------- | ------------------------- | -- | --------- |
+| names | Array | Yes| Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
**Example**
```js
// In this example, the status bar and navigation bar are not displayed.
let names = [];
-windowClass.setSystemBarEnable(names, (err, data) => {
- if (err.code) {
- console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.setWindowSystemBarEnable(names, (err) => {
+ if (err.code) {
+ console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the system bar to be invisible.');
+ });
+} catch (exception) {
+ console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
+};
```
-### setSystemBarEnable7+
+### setWindowSystemBarEnable9+
-setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>
+setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>
Sets whether to display the status bar and navigation bar in this window. This API uses a promise to return the result.
@@ -1573,32 +2017,45 @@ Sets whether to display the status bar and navigation bar in this window. This A
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ----- | ---- | ------------------------------------------------------------ |
-| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to `['status', 'navigation']`. By default, they are not displayed.|
+| Name| Type | Mandatory| Description|
+| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ |
+| names | Array | Yes| Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed.|
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
+| Type| Description|
+| ------------------- | ------------------------ |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
// In this example, the status bar and navigation bar are not displayed.
let names = [];
-let promise = windowClass.setSystemBarEnable(names);
-promise.then((data)=> {
- console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
-});
+try {
+ let promise = windowClass.setWindowSystemBarEnable(names);
+ promise.then(()=> {
+ console.info('Succeeded in setting the system bar to be invisible.');
+ }).catch((err)=>{
+ console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
+};
```
-### setSystemBarProperties
+### setWindowSystemBarProperties9+
-setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void
+setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void
Sets the properties of the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.
@@ -1611,31 +2068,41 @@ Sets the properties of the status bar and navigation bar in this window. This AP
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
let SystemBarProperties={
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
- // The following properties are supported since API version 7.
- isStatusBarLightIcon: true,
- isNavigationBarLightIcon:false,
// The following properties are supported since API version 8.
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
-windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {
- if (err.code) {
- console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => {
+ if (err.code) {
+ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the system bar properties.');
+ });
+} catch (exception) {
+ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
+};
```
-### setSystemBarProperties
+### setWindowSystemBarProperties9+
-setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void>
+setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void>
Sets the properties of the status bar and navigation bar in this window. This API uses a promise to return the result.
@@ -1653,25 +2120,35 @@ Sets the properties of the status bar and navigation bar in this window. This AP
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
let SystemBarProperties={
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
- // The following properties are supported since API version 7.
- isStatusBarLightIcon: true,
- isNavigationBarLightIcon:false,
// The following properties are supported since API version 8.
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
-let promise = windowClass.setSystemBarProperties(SystemBarProperties);
-promise.then((data)=> {
- console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
-});
+try {
+ let promise = windowClass.setWindowSystemBarProperties(SystemBarProperties);
+ promise.then(()=> {
+ console.info('Succeeded in setting the system bar properties.');
+ }).catch((err)=>{
+ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
+};
```
### setPreferredOrientation9+
@@ -1689,17 +2166,29 @@ Sets the preferred orientation for this window. This API uses an asynchronous ca
| Orientation | [Orientation](#orientation9) | Yes | Orientation to set. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
**Example**
```js
let orientation = window.Orientation.AUTO_ROTATION;
-windowClass.setPreferredOrientation(orientation, (err, data) => {
- if (err.code) {
- console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.setPreferredOrientation(orientation, (err) => {
+ if (err.code) {
+ console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting window orientation.');
+ });
+} catch (exception) {
+ console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
+};
```
### setPreferredOrientation9+
@@ -1722,21 +2211,33 @@ Sets the preferred orientation for this window. This API uses a promise to retur
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
**Example**
```js
let orientation = window.Orientation.AUTO_ROTATION;
-let promise = windowClass.setPreferredOrientation(orientation);
-promise.then((data)=> {
- console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
-});
+try {
+ let promise = windowClass.setPreferredOrientation(orientation);
+ promise.then(()=> {
+ console.info('Succeeded in setting the window orientation.');
+ }).catch((err)=>{
+ console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
+};
```
-### loadContent7+
+### setUIContent9+
-loadContent(path: string, callback: AsyncCallback<void>): void
+setUIContent(path: string, callback: AsyncCallback<void>): void
Loads content from a page to this window. This API uses an asynchronous callback to return the result.
@@ -1744,26 +2245,39 @@ Loads content from a page to this window. This API uses an asynchronous callback
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | -------------------- |
-| path | string | Yes | Path of the page from which the content will be loaded.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name| Type| Mandatory| Description|
+| -------- | ------------------------- | -- | -------------------- |
+| path | string | Yes| Path of the page from which the content will be loaded.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
**Example**
```js
-windowClass.loadContent('pages/page2/page2', (err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.setUIContent('pages/page2/page2', (err) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content.');
+ });
+} catch (exception) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
+};
```
-### loadContent7+
+### setUIContent9+
-loadContent(path: string): Promise<void>
+setUIContent(path: string): Promise<void>
Loads content from a page to this window. This API uses a promise to return the result.
@@ -1771,26 +2285,40 @@ Loads content from a page to this window. This API uses a promise to return the
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | -------------------- |
-| path | string | Yes | Path of the page from which the content will be loaded.|
+| Name| Type| Mandatory| Description|
+| ---- | ------ | -- | ------------------ |
+| path | string | Yes| Path of the page from which the content will be loaded.|
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
+| Type| Description|
+| ------------------- | ------------------------ |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
-let promise = windowClass.loadContent('pages/page2/page2');
-promise.then((data)=> {
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
-});
+try {
+ let promise = windowClass.setUIContent('pages/page2/page2');
+ promise.then(()=> {
+ console.info('Succeeded in loading the content.');
+ }).catch((err)=>{
+ console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
+};
```
+
### loadContent9+
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void
@@ -1806,27 +2334,35 @@ Loads content from a page associated with a local storage to this window. This A
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Path of the page from which the content will be loaded. |
-| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
+| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```ts
-class myAbility extends Ability {
- storage : LocalStorage
- onWindowStageCreate(windowStage) {
- this.storage = new LocalStorage();
- this.storage.setOrCreate('storageSimpleProp',121);
- console.log('onWindowStageCreate');
- windowStage.loadContent('pages/page2',this.storage,(err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
- });
- }
-}
+let storage = new LocalStorage();
+storage.setOrCreate('storageSimpleProp',121);
+console.log('onWindowStageCreate');
+try {
+ windowClass.loadContent('pages/page2', storage, (err) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content.');
+ });
+} catch (exception) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
+};
```
### loadContent9+
@@ -1844,7 +2380,7 @@ Loads content from a page associated with a local storage to this window. This A
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Path of the page from which the content will be loaded. |
-| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
+| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
**Return value**
@@ -1852,75 +2388,64 @@ Loads content from a page associated with a local storage to this window. This A
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
-**Example**
-
-```ts
-class myAbility extends Ability {
- storage : LocalStorage
- onWindowStageCreate(windowStage) {
- this.storage = new LocalStorage();
- this.storage.setOrCreate('storageSimpleProp',121);
- console.log('onWindowStageCreate');
- let windowClass = null;
- let promise = windowStage.loadContent('pages/page2',this.storage);
- promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
- }).catch((err)=>{
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- })
- }
-}
-```
-### isShowing7+
-
-isShowing(callback: AsyncCallback<boolean>): void
-
-Checks whether this window is displayed. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Error codes**
-**Parameters**
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that the window is displayed, and `false` means the opposite.|
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
**Example**
-```js
-windowClass.isShowing((err, data) => {
- if (err.code) {
- console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
-});
+```ts
+let storage = new LocalStorage();
+storage.setOrCreate('storageSimpleProp',121);
+console.log('onWindowStageCreate');
+try {
+ let promise = windowClass.loadContent('pages/page2', storage);
+ promise.then(() => {
+ console.info('Succeeded in loading the content.');
+ }).catch((err) => {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
+};
```
-### isShowing7+
+### isWindowShowing9+
-isShowing(): Promise<boolean>
+isWindowShowing(): boolean
-Checks whether this window is displayed. This API uses a promise to return the result.
+Checks whether this window is displayed.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
-| Type | Description |
-| ---------------------- | ------------------------------------------------------------ |
-| Promise<boolean> | Promise used to return the result. The value `true` means that the window is displayed, and `false` means the opposite.|
+| Type| Description|
+| ------- | ------------------------------------------------------------------ |
+| boolean | Whether the window is displayed. The value **true** means that the window is displayed, and **false** means the opposite.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
**Example**
```js
-let promise = windowClass.isShowing();
-promise.then((data)=> {
+try {
+ let data = windowClass.isWindowShowing();
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
-});
+} catch (exception) {
+ console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
+};
```
### on('windowSizeChange')7+
@@ -1935,20 +2460,24 @@ Enables listening for window size changes.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------ | ---- | -------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.|
+| type | string | Yes | Event type. The value is fixed at **'windowSizeChange'**, indicating the window size change event.|
| callback | Callback<[Size](#size7)> | Yes | Callback used to return the window size. |
**Example**
```js
-windowClass.on('windowSizeChange', (data) => {
- console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.on('windowSizeChange', (data) => {
+ console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
+};
```
### off('windowSizeChange')7+
-off(type: 'windowSizeChange', callback?: Callback<Size >): void
+off(type: 'windowSizeChange', callback?: Callback<Size>): void
Disables listening for window size changes.
@@ -1958,69 +2487,22 @@ Disables listening for window size changes.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.|
+| type | string | Yes | Event type. The value is fixed at **'windowSizeChange'**, indicating the window size change event.|
| callback | Callback<[Size](#size)> | No | Callback used to return the window size. |
**Example**
```js
-windowClass.off('windowSizeChange');
-```
-
-### on('systemAvoidAreaChange')(deprecated)
-
-on(type: 'systemAvoidAreaChange', callback: Callback<[AvoidArea](#avoidarea7)>): void
-
-Enables listening for changes to the area where the window cannot be displayed.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
-| callback | Callback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. |
-
-**Example**
-
-```js
-windowClass.on('systemAvoidAreaChange', (data) => {
- console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
-});
-```
-
-### off('systemAvoidAreaChange')(deprecated)
-
-off(type: 'systemAvoidAreaChange', callback?: Callback<[AvoidArea](#avoidarea7)>): void
-
-Disables listening for changes to the area where the window cannot be displayed.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
-| callback | Callback<[AvoidArea](#avoidarea7)> | No | Callback used to return the area. |
-
-**Example**
-
-```js
-windowClass.off('systemAvoidAreaChange');
+try {
+ windowClass.off('windowSizeChange');
+} catch (exception) {
+ console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
+};
```
-
### on('avoidAreaChange')9+
-on(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void
+on(type: 'avoidAreaChange', callback: Callback<{AvoidAreaType, AvoidArea}>): void
Enables listening for changes to the area where the window cannot be displayed.
@@ -2030,20 +2512,25 @@ Enables listening for changes to the area where the window cannot be displayed.
| Name | Type | Mandatory| Description |
| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
-| type | string | Yes | Event type. The value is fixed at `avoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
+| type | string | Yes | Event type. The value is fixed at **'avoidAreaChange'**, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | Yes | Callback used to return the area and area type.|
**Example**
```js
-windowClass.on('avoidAreaChange', (data) => {
- console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area));
-});
+try {
+ windowClass.on('avoidAreaChange', (data) => {
+ console.info('Succeeded in enabling the listener for system avoid area changes. type:' +
+ JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area));
+ });
+} catch (exception) {
+ console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
+};
```
### off('avoidAreaChange')9+
-off(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void
+off(type: 'avoidAreaChange', callback: Callback<{AvoidAreaType, AvoidArea}>): void
Disables listening for changes to the area where the window cannot be displayed.
@@ -2053,13 +2540,17 @@ Disables listening for changes to the area where the window cannot be displayed.
| Name | Type | Mandatory | Description |
| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
-| type | string | Yes | Event type. The value is fixed at `avoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
+| type | string | Yes | Event type. The value is fixed at **'avoidAreaChange'**, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | No | Callback used to return the area and area type.|
**Example**
```js
-windowClass.off('avoidAreaChange');
+try {
+ windowClass.off('avoidAreaChange');
+} catch (exception) {
+ console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
+};
```
### on('keyboardHeightChange')7+
@@ -2074,15 +2565,19 @@ Enables listening for keyboard height changes.
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
-| callback | Callback {
- console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
-});
+try {
+ windowClass.on('keyboardHeightChange', (data) => {
+ console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
+};
```
### off('keyboardHeightChange')7+
@@ -2097,13 +2592,17 @@ Disables listening for keyboard height changes.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
+| type | string | Yes | Event type. The value is fixed at **'keyboardHeightChange'**, indicating the keyboard height change event.|
| callback | Callback<number> | No | Callback used to return the current keyboard height. |
**Example**
```js
-windowClass.off('keyboardHeightChange');
+try {
+ windowClass.off('keyboardHeightChange');
+} catch (exception) {
+ console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
+};
```
### on('touchOutside')9+
@@ -2120,15 +2619,19 @@ Enables listening for click events outside this window.
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `touchOutside`, indicating the click event outside this window.|
-| callback | Callback {
- console.info('touch outside');
-});
+try {
+ windowClass.on('touchOutside', () => {
+ console.info('touch outside');
+ });
+} catch (exception) {
+ console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
+};
```
### off('touchOutside')9+
@@ -2145,13 +2648,17 @@ Disables listening for click events outside this window.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `touchOutside`, indicating the click event outside this window.|
-| callback | Callback<number> | No | Callback used to Callback used to return the click event outside this window. |
+| type | string | Yes | Event type. The value is fixed at **'touchOutside'**, indicating the click event outside this window.|
+| callback | Callback<number> | No | Callback used to return the click event outside this window. |
**Example**
```js
-windowClass.off('touchOutside');
+try {
+ windowClass.off('touchOutside');
+} catch (exception) {
+ console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
+};
```
### on('screenshot')9+
@@ -2166,15 +2673,19 @@ Subscribes to screenshot events.
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `screenshot`, indicating the screenshot event.|
+| type | string | Yes | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
| callback | Callback<void> | Yes | Callback invoked when a screenshot event occurs. |
**Example**
```js
-windowClass.on('screenshot', () => {
- console.info('screenshot happened');
-});
+try {
+ windowClass.on('screenshot', () => {
+ console.info('screenshot happened');
+ });
+} catch (exception) {
+ console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
+};
```
### off('screenshot')9+
@@ -2189,7 +2700,7 @@ Unsubscribes from screenshot events.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `screenshot`, indicating the screenshot event.|
+| type | string | Yes | Event type. The value is fixed at **'screenshot'**, indicating the screenshot event.|
| callback | Callback<void> | No | Callback invoked when a screenshot event occurs.|
**Example**
@@ -2197,12 +2708,19 @@ Unsubscribes from screenshot events.
```js
let callback = ()=>{
console.info('screenshot happened');
-}
-windowClass.on('screenshot', callback)
-windowClass.off('screenshot', callback)
-
-// If multiple callbacks are enabled in on(), they will all be disabled.
-windowClass.off('screenshot');
+};
+try {
+ windowClass.on('screenshot', callback);
+} catch (exception) {
+ console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
+};
+try {
+ windowClass.off('screenshot', callback);
+ // If multiple callbacks are enabled in on(), they will all be disabled.
+ windowClass.off('screenshot');
+} catch (exception) {
+ console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
+};
```
### on('dialogTargetTouch')9+
@@ -2217,15 +2735,19 @@ Subscribes to click events of the target window in the modal window mode.
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `dialogTargetTouch`, indicating the click event of the target window in the modal window mode.|
+| type | string | Yes | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.|
| callback | Callback<void>| Yes | Callback invoked when the click event occurs in the target window of the modal window mode.|
**Example**
```js
-windowClass.on('dialogTargetTouch', () => {
- console.info('touch dialog target');
-});
+try {
+ windowClass.on('dialogTargetTouch', () => {
+ console.info('touch dialog target');
+ });
+} catch (exception) {
+ console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
+};
```
### off('dialogTargetTouch')9+
@@ -2240,13 +2762,17 @@ Unsubscribes from click events of the target window in the modal window mode.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `dialogTargetTouch`, indicating the click event of the target window in the modal window mode.|
+| type | string | Yes | Event type. The value is fixed at **'dialogTargetTouch'**, indicating the click event of the target window in the modal window mode.|
| callback | Callback<void> | No | Callback invoked when the click event occurs in the target window of the modal window mode.|
**Example**
```js
-windowClass.off('dialogTargetTouch');
+try {
+ windowClass.off('dialogTargetTouch');
+} catch (exception) {
+ console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
+};
```
### bindDialogTarget9+
@@ -2267,6 +2793,15 @@ Binds the modal window to the target window, and adds a callback to listen for m
| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
@@ -2290,15 +2825,19 @@ class TestRemoteObject extends rpc.RemoteObject {
}
}
let token = new TestRemoteObject('testObject');
-windowClass.bindDialogTarget(token, () => {
- console.info('Dialog Window Need Destroy.');
-}, (err, data) => {
- if (err.code) {
- console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data));
-});
+try {
+ windowClass.bindDialogTarget(token, () => {
+ console.info('Dialog Window Need Destroy.');
+ }, (err) => {
+ if (err.code) {
+ console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in binding dialog target.');
+ });
+} catch (exception) {
+ console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
+};
```
### bindDialogTarget9+
@@ -2324,6 +2863,15 @@ Binds the modal window to the target window, and adds a callback to listen for m
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
**Example**
```js
@@ -2347,1108 +2895,2950 @@ class TestRemoteObject extends rpc.RemoteObject {
}
}
let token = new TestRemoteObject('testObject');
-let promise = windowClass.bindDialogTarget(token, () => {
- console.info('Dialog Window Need Destroy.');
+try {
+ let promise = windowClass.bindDialogTarget(token, () => {
+ console.info('Dialog Window Need Destroy.');
+ });
+ promise.then(()=> {
+ console.info('Succeeded in binding dialog target.');
+ }).catch((err)=>{
+ console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
+};
+```
+
+### isWindowSupportWideGamut9+
+
+isWindowSupportWideGamut(callback: AsyncCallback<boolean>): void
+
+Checks whether this window supports the wide-gamut color space. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- |
+| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+windowClass.isWindowSupportWideGamut((err, data) => {
+ if (err.code) {
+ console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
});
+```
+
+### isWindowSupportWideGamut9+
+
+isWindowSupportWideGamut(): Promise<boolean>
+
+Checks whether this window supports the wide-gamut color space. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type| Description|
+| ---------------------- | ------------------------------------------------------------------------------------ |
+| Promise<boolean> | Promise used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let promise = windowClass.isWindowSupportWideGamut();
promise.then((data)=> {
- console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data));
+ console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
+ console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
});
```
-### isSupportWideGamut8+
+### setWindowColorSpace9+
-isSupportWideGamut(callback: AsyncCallback<boolean>): void
+setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void
-Checks whether this window supports the wide color gamut mode. This API uses an asynchronous callback to return the result.
+Sets a color space for this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.|
+| Name| Type| Mandatory| Description|
+| ---------- | ------------------------- | -- | ----------- |
+| colorSpace | [ColorSpace](#colorspace) | Yes| Color space to set.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
**Example**
```js
-windowClass.isSupportWideGamut((err, data) => {
+try {
+ windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
+ if (err.code) {
+ console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting window colorspace.');
+ });
+} catch (exception) {
+ console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowColorSpace9+
+
+setWindowColorSpace(colorSpace:ColorSpace): Promise<void>
+
+Sets a color space for this window. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ---------- | ------------------------- | -- | ------------- |
+| colorSpace | [ColorSpace](#colorspace) | Yes| Color space to set.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+try {
+ let promise = windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT);
+ promise.then(()=> {
+ console.info('Succeeded in setting window colorspace.');
+ }).catch((err)=>{
+ console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
+};
+```
+
+### getWindowColorSpace9+
+
+getWindowColorSpace(): ColorSpace
+
+Obtains the color space of this window.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type| Description|
+| ------------------------- | ------------- |
+| [ColorSpace](#colorspace) | Color space obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let colorSpace = windowClass.getWindowColorSpace();
+```
+
+### setWindowBackgroundColor9+
+
+setWindowBackgroundColor(color: string): void
+
+Sets the background color for this window. In the stage model, this API must be used after [loadContent](#loadcontent9).
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ----- | ------ | -- | ----------------------------------------------------------------------- |
+| color | string | Yes| Background color to set. The value is a hexadecimal color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let color = '#00ff33';
+try {
+ windowClass.setWindowBackgroundColor(color);
+} catch (exception) {
+ console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowBrightness9+
+
+setWindowBrightness(brightness: number, callback: AsyncCallback<void>): void
+
+Sets the screen brightness for this window. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ---------- | ------------------------- | -- | --------------------------------- |
+| brightness | number | Yes| Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let brightness = 1;
+try {
+ windowClass.setWindowBrightness(brightness, (err) => {
+ if (err.code) {
+ console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the brightness.');
+ });
+} catch (exception) {
+ console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowBrightness9+
+
+setWindowBrightness(brightness: number): Promise<void>
+
+Sets the screen brightness for this window. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ---------- | ------ | -- | --------------------------------- |
+| brightness | number | Yes| Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let brightness = 1;
+try {
+ let promise = windowClass.setWindowBrightness(brightness);
+ promise.then(()=> {
+ console.info('Succeeded in setting the brightness.');
+ }).catch((err)=>{
+ console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowFocusable9+
+
+setWindowFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void
+
+Sets whether this window can gain focus. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ----------- | ------------------------- | -- | ------------------------------------------------------- |
+| isFocusable | boolean | Yes| Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isFocusable= true;
+try {
+ windowClass.setWindowFocusable(isFocusable, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window to be focusable.');
+ });
+} catch (exception) {
+ console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowFocusable9+
+
+setWindowFocusable(isFocusable: boolean): Promise<void>
+
+Sets whether this window can gain focus. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ----------- | ------- | -- | -------------------------------------------------------- |
+| isFocusable | boolean | Yes| Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite. |
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isFocusable= true;
+try {
+ let promise = windowClass.setWindowFocusable(isFocusable);
+ promise.then(()=> {
+ console.info('Succeeded in setting the window to be focusable.');
+ }).catch((err)=>{
+ console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowKeepScreenOn9+
+
+setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void
+
+Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------------- | ------------------------- | -- | ---------------------------------------------------- |
+| isKeepScreenOn | boolean | Yes| Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isKeepScreenOn = true;
+try {
+ windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err) => {
+ if (err.code) {
+ console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the screen to be always on.');
+ });
+} catch (exception) {
+ console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowKeepScreenOn9+
+
+setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise<void>
+
+Sets whether to keep the screen always on. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------------- | ------- | -- | --------------------------------------------------- |
+| isKeepScreenOn | boolean | Yes| Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isKeepScreenOn = true;
+try {
+ let promise = windowClass.setWindowKeepScreenOn(isKeepScreenOn);
+ promise.then(() => {
+ console.info('Succeeded in setting the screen to be always on.');
+ }).catch((err)=>{
+ console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWakeUpScreen()9+
+
+setWakeUpScreen(wakeUp: boolean): void
+
+Wakes up the screen.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------------- | ------- | ---- | ---------------------------- |
+| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let wakeUp = true;
+try {
+ windowClass.setWakeUpScreen(wakeUp);
+} catch (exception) {
+ console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowPrivacyMode9+
+
+setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void
+
+Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Required permissions**: ohos.permission.PRIVACY_WINDOW
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ------------- | ------------------------- | -- | ------------------------------------------------------ |
+| isPrivacyMode | boolean | Yes| Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let isPrivacyMode = true;
+try {
+ windowClass.setWindowPrivacyMode(isPrivacyMode, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window to privacy mode.');
+ });
+} catch (exception) {
+ console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowPrivacyMode9+
+
+setWindowPrivacyMode(isPrivacyMode: boolean): Promise<void>
+
+Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Required permissions**: ohos.permission.PRIVACY_WINDOW
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ------------- | ------- | -- | ----------------------------------------------------- |
+| isPrivacyMode | boolean | Yes| Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------ |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let isPrivacyMode = true;
+try {
+ let promise = windowClass.setWindowPrivacyMode(isPrivacyMode);
+ promise.then(()=> {
+ console.info('Succeeded in setting the window to privacy mode.');
+ }).catch((err)=>{
+ console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setSnapshotSkip9+
+setSnapshotSkip(isSkip: boolean): void
+
+Sets whether to ignore this window during screen capturing or recording.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------------- | ------- | ---- | -------------------- |
+| isSkip | boolean | Yes | Whether to ignore the window. The default value is **false**.
The value **true** means that the window is ignored, and **false** means the opposite.
|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+```js
+let isSkip = true;
+try {
+ windowClass.setSnapshotSkip(isSkip);
+} catch (exception) {
+ console.error('Failed to Skip. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setWindowTouchable9+
+
+setWindowTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void
+
+Sets whether this window is touchable. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ----------- | ------------------------- | -- | ----------------------------------------------- |
+| isTouchable | boolean | Yes| Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isTouchable = true;
+try {
+ windowClass.setWindowTouchable(isTouchable, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window to be touchable.');
+ });
+} catch (exception) {
+ console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setWindowTouchable9+
+
+setWindowTouchable(isTouchable: boolean): Promise<void>
+
+Sets whether this window is touchable. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ----------- | ------- | -- | ----------------------------------------------- |
+| isTouchable | boolean | Yes| Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite.|
+
+**Return value**
+
+| Type| Description|
+| ------------------- | ------------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isTouchable = true;
+try {
+ let promise = windowClass.setWindowTouchable(isTouchable);
+ promise.then(()=> {
+ console.info('Succeeded in setting the window to be touchable.');
+ }).catch((err)=>{
+ console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setForbidSplitMove9+
+
+setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void
+
+Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------------------------- | ---- | -------------------- |
+| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode. The value **true** means the window is forbidden to move in split-screen mode, and **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isForbidSplitMove = true;
+try {
+ windowClass.setForbidSplitMove(isForbidSplitMove, (err) => {
+ if (err.code) {
+ console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in forbidding window moving in split screen mode.');
+ });
+} catch (exception) {
+ console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
+};
+```
+
+### setForbidSplitMove9+
+
+setForbidSplitMove(isForbidSplitMove: boolean): Promise<void>
+
+Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------- | ---- | -------------------- |
+| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode. The value **true** means the window is forbidden to move in split-screen mode, and **false** means the opposite.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID| Error Message|
+| ------- | -------------------------------------------- |
+| 1300002 | This window state is abnormal. |
+| 1300003 | This window manager service works abnormally. |
+
+**Example**
+
+```js
+let isForbidSplitMove = true;
+try {
+ let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
+ promise.then(()=> {
+ console.info('Succeeded in forbidding window moving in split screen mode.');
+ }).catch((err)=>{
+ console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
+};
+```
+
+### snapshot9+
+
+snapshot(callback: AsyncCallback<image.PixelMap>): void
+
+Captures this window. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------------------------------------------ | --------- | ----------------------------------- |
+| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+windowClass.snapshot((err, pixelMap) => {
+ if (err.code) {
+ console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
+ pixelMap.release(); // Release the memory in time after the PixelMap is used.
+});
+```
+
+### snapshot9+
+
+snapshot(): Promise<image.PixelMap>
+
+Captures this window. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | --------------------------------------------- |
+| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise used to return the window screenshot. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+
+**Example**
+
+```js
+let promise = windowClass.snapshot();
+promise.then((pixelMap)=> {
+ console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
+ pixelMap.release(); // Release the memory in time after the PixelMap is used.
+}).catch((err)=>{
+ console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
+});
+```
+
+### opacity9+
+
+opacity(opacity: number): void
+
+Sets the opacity for this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | ------ | --------- | ------------------------------------------------- |
+| opacity | number | Yes | Opacity to set. The value ranges from 0.0 to 1.0. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+try {
+ windowClass.opacity(0.5);
+} catch (exception) {
+ console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### scale9+
+
+scale(scaleOptions: ScaleOptions): void
+
+Sets the scale parameters for this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | ------------------------------ | --------- | ------------------------ |
+| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes | Scale parameters to set. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+let obj : window.ScaleOptions = {
+ x : 2.0,
+ y : 1.0,
+ pivotX : 0.5,
+ pivotY : 0.5
+};
+try {
+ windowClass.scale(obj);
+} catch (exception) {
+ console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### rotate9+
+
+rotate(rotateOptions: RotateOptions): void
+
+Sets the rotation parameters for this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------- | -------------------------------- | --------- | --------------------------- |
+| rotateOptions | [RotateOptions](#rotateoptions9) | Yes | Rotation parameters to set. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+let obj : window.RotateOptions = {
+ x : 1.0,
+ y : 1.0,
+ z : 45.0,
+ pivotX : 0.5,
+ pivotY : 0.5
+};
+try {
+ windowClass.rotate(obj);
+} catch (exception) {
+ console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### translate9+
+
+translate(translateOptions: TranslateOptions): void
+
+Sets the translation parameters for this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------------- | -------------------------------------- | --------- | ------------------------------ |
+| translateOptions | [TranslateOptions](#translateoptions9) | Yes | Translation parameters to set. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+let obj : window.TranslateOptions = {
+ x : 100.0,
+ y : 0.0,
+ z : 0.0
+};
+try {
+ windowClass.translate(obj);
+} catch (exception) {
+ console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### getTransitionController9+
+
+ getTransitionController(): TransitionController
+
+Obtains the transition animation controller.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------------- | -------------------------------- |
+| [TransitionController](#transitioncontroller9) | Transition animation controller. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+let controller = windowClass.getTransitionController(); // Obtain the transition animation controller.
+controller.animationForHidden = (context : window.TransitionContext) => {
+ let toWindow = context.toWindow;
+ animateTo({
+ duration: 1000, // Animation duration.
+ tempo: 0.5, // Playback speed.
+ curve: Curve.EaseInOut, // Animation curve.
+ delay: 0, // Animation delay.
+ iterations: 1, // Number of playback times.
+ playMode: PlayMode.Normal // Animation playback mode.
+ onFinish: ()=> {
+ context.completeTransition(true)
+ }
+ }, () => {
+ let obj : window.TranslateOptions = {
+ x : 100.0,
+ y : 0.0,
+ z : 0.0
+ };
+ toWindow.translate(obj); // Set the transition animation.
+ console.info('toWindow translate end');
+ }
+ )
+ console.info('complete transition end');
+}
+windowClass.hideWithAnimation((err, data) => {
+ if (err.code) {
+ console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
+})
+```
+
+### setBlur9+
+
+setBlur(radius: number): void
+
+Blurs this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | --------- | ------------------------------------------------------------ |
+| radius | number | Yes | Radius of the blur. The value is greater than or equal to 0. The value **0** means that the blur is disabled for the window. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+try {
+ windowClass.setBlur(4.0);
+} catch (exception) {
+ console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setBackdropBlur9+
+
+setBackdropBlur(radius: number): void
+
+Blurs the background of this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | --------- | ------------------------------------------------------------ |
+| radius | number | Yes | Radius of the blur. The value is greater than or equal to 0. The value **0** means that the blur is disabled for the background of the window. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+try {
+ windowClass.setBackdropBlur(4.0);
+} catch (exception) {
+ console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setBackdropBlurStyle9+
+
+setBackdropBlurStyle(blurStyle: BlurStyle): void
+
+Sets the blur style for the background of this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------ | --------- | --------------------------------------------------- |
+| blurStyle | [BlurStyle](#blurstyle9) | Yes | Blur style to set for the background of the window. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+try {
+ windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
+} catch (exception) {
+ console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setShadow9+
+
+setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
+
+Sets the shadow for the window borders.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | ------ | --------- | ------------------------------------------------------------ |
+| radius | number | Yes | Radius of the shadow. The value is greater than or equal to 0. The value **0** means that the shadow is disabled for the window borders. |
+| color | string | No | Color of the shadow. The value is a hexadecimal color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. |
+| offsetX | number | No | Offset of the shadow along the x-axis, in pixels. |
+| offsetY | number | No | Offset of the shadow along the y-axis, in pixels. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+try {
+ windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
+} catch (exception) {
+ console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### setCornerRadius9+
+
+setCornerRadius(cornerRadius: number): void
+
+Sets the radius of the rounded corners for this window.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | --------- | ------------------------------------------------------------ |
+| radius | number | Yes | Radius of the rounded corners. The value is greater than or equal to 0. The value **0** means that the window does not use rounded corners. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300004 | Unauthorized operation. |
+
+**Example**
+
+```js
+try {
+ windowClass.setCornerRadius(4.0);
+} catch (exception) {
+ console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
+};
+```
+
+### show(deprecated)
+
+show(callback: AsyncCallback<void>): void
+
+Shows this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [showWindow()](#showwindow9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ----------------------------------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+windowClass.show((err) => {
+ if (err.code) {
+ console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in showing the window.');
+})
+```
+
+### show(deprecated)
+
+show(): Promise<void>
+
+Shows this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [showWindow()](#showwindow9-1) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
+
+**Example**
+
+```js
+let promise = windowClass.show();
+promise.then(()=> {
+ console.info('Succeeded in showing the window.');
+}).catch((err)=>{
+ console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
+})
+```
+
+### destroy(deprecated)
+
+destroy(callback: AsyncCallback<void>): void
+
+Destroys this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [destroyWindow()](#destroywindow9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ----------------------------------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+windowClass.destroy((err) => {
+ if (err.code) {
+ console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in destroying the window.');
+})
+```
+
+### destroy(deprecated)
+
+destroy(): Promise<void>
+
+Destroys this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [destroyWindow()](#destroywindow9-1) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
+
+**Example**
+
+```js
+let promise = windowClass.destroy();
+promise.then(()=> {
+ console.info('Succeeded in destroying the window.');
+}).catch((err)=>{
+ console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
+})
+```
+
+### moveTo(deprecated)
+
+moveTo(x: number, y: number, callback: AsyncCallback<void>): void
+
+Moves this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [moveWindowTo()](#movewindowto9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right. |
+| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+windowClass.moveTo(300, 300, (err)=>{
+ if (err.code) {
+ console.error('Failed to move the window. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in moving the window.');
+
+});
+```
+
+### moveTo(deprecated)
+
+moveTo(x: number, y: number): Promise<void>
+
+Moves this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [moveWindowTo()](#movewindowto9-1) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | --------- | ------------------------------------------------------------ |
+| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right. |
+| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
+
+**Example**
+
+```js
+let promise = windowClass.moveTo(300, 300);
+promise.then(()=> {
+ console.info('Succeeded in moving the window.');
+}).catch((err)=>{
+ console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
+})
+```
+
+### resetSize(deprecated)
+
+resetSize(width: number, height: number, callback: AsyncCallback<void>): void
+
+Changes the size of this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ----------------------------------- |
+| width | number | Yes | New width of the window, in px. |
+| height | number | Yes | New height of the window, in px. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+windowClass.resetSize(500, 1000, (err) => {
+ if (err.code) {
+ console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in changing the window size.');
+});
+```
+
+### resetSize(deprecated)
+
+resetSize(width: number, height: number): Promise<void>
+
+Changes the size of this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [resize()](#resize9-1) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | --------- | -------------------------------- |
+| width | number | Yes | New width of the window, in px. |
+| height | number | Yes | New height of the window, in px. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
+
+**Example**
+
+```js
+let promise = windowClass.resetSize(500, 1000);
+promise.then(()=> {
+ console.info('Succeeded in changing the window size.');
+}).catch((err)=>{
+ console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
+});
+
+```
+
+### setWindowType(deprecated)
+
+setWindowType(type: WindowType, callback: AsyncCallback<void>): void
+
+Sets the type of this window. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------- | --------- | ----------------------------------- |
+| type | [WindowType](#windowtype7) | Yes | Window type. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+let type = window.WindowType.TYPE_APP;
+windowClass.setWindowType(type, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window type.');
+});
+```
+
+### setWindowType(deprecated)
+
+setWindowType(type: WindowType): Promise<void>
+
+Sets the type of this window. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | -------------------------- | --------- | ------------ |
+| type | [WindowType](#windowtype7) | Yes | Window type. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
+
+**Example**
+
+```js
+let type = window.WindowType.TYPE_APP;
+let promise = windowClass.setWindowType(type);
+promise.then(()=> {
+ console.info('Succeeded in setting the window type.');
+}).catch((err)=>{
+ console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
+});
+```
+
+### getProperties(deprecated)
+
+getProperties(callback: AsyncCallback<WindowProperties>): void
+
+Obtains the properties of this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getWindowProperties()](#getwindowproperties9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------------------------- | --------- | ---------------------------------------------- |
+| callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties. |
+
+**Example**
+
+```js
+windowClass.getProperties((err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
+});
+
+```
+
+### getProperties(deprecated)
+
+getProperties(): Promise<WindowProperties>
+
+Obtains the properties of this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getWindowProperties()](#getwindowproperties9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------------------- | --------------------------------------------- |
+| Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties. |
+
+**Example**
+
+```js
+let promise = windowClass.getProperties();
+promise.then((data)=> {
+ console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
+}).catch((err)=>{
+ console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
+});
+
+```
+
+### getAvoidArea(deprecated)
+
+getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void
+
+Obtains the area where this window cannot be displayed, for example, the system bar area, notch, gesture area, and soft keyboard area. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [[getWindowAvoidArea()](#getwindowavoidarea9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------ |
+| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area. |
+| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. |
+
+**Example**
+
+```js
+let type = window.AvoidAreaType.TYPE_SYSTEM;
+windowClass.getAvoidArea(type, (err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
+});
+```
+
+### getAvoidArea(deprecated)
+
+getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)>
+
+Obtains the area where this window cannot be displayed, for example, the system bar area, notch, gesture area, and soft keyboard area. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getWindowProperties()](#getwindowavoidarea9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | -------------------------------- | --------- | ------------------------------------------------------------ |
+| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area. |
+
+**Return value**
+
+| Type | Description |
+| --------------------------------------- | -------------------------------- |
+| Promise<[AvoidArea](#avoidarea7)> | Promise used to return the area. |
+
+**Example**
+
+```js
+let type = window.AvoidAreaType.TYPE_SYSTEM;
+let promise = windowClass.getAvoidArea(type);
+promise.then((data)=> {
+ console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
+}).catch((err)=>{
+ console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
+});
+```
+
+### setFullScreen(deprecated)
+
+setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void
+
+Sets whether to enable the full-screen mode for this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) instead.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | ------------------------- | --------- | ------------------------------------------------------------ |
+| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden. The value **true** means to enable the full-screen mode, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+let isFullScreen = true;
+windowClass.setFullScreen(isFullScreen, (err) => {
if (err.code) {
- console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
+ console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
-})
+ console.info('Succeeded in enabling the full-screen mode.');
+});
```
-### isSupportWideGamut8+
+### setFullScreen(deprecated)
-isSupportWideGamut(): Promise<boolean>
+setFullScreen(isFullScreen: boolean): Promise<void>
-Checks whether this window supports the wide color gamut mode. This API uses a promise to return the result.
+Sets whether to enable the full-screen mode for this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | ------- | --------- | ------------------------------------------------------------ |
+| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden. The value **true** means to enable the full-screen mode, and **false** means the opposite. |
+
**Return value**
-| Type | Description |
-| ---------------------- | ------------------------------------------------------------ |
-| Promise<boolean> | Promise used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let promise = windowClass.isSupportWideGamut();
-promise.then((data)=> {
- console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
+let isFullScreen = true;
+let promise = windowClass.setFullScreen(isFullScreen);
+promise.then(()=> {
+ console.info('Succeeded in enabling the full-screen mode.');
}).catch((err)=>{
- console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
+ console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
});
+
```
-### setColorSpace8+
+### setLayoutFullScreen(deprecated)
-setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void
+setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void
+
+Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result.
-Sets this window to the wide or default color gamut mode. This API uses an asynchronous callback to return the result.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------------------------- | ---- | ------------ |
-| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| ------------------ | ------------------------- | --------- | ------------------------------------------------------------ |
+| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {
+let isLayoutFullScreen= true;
+windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => {
if (err.code) {
- console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
+ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
-})
+ console.info('Succeeded in setting the window layout to full-screen mode.');
+});
+
```
-### setColorSpace8+
+### setLayoutFullScreen(deprecated)
-setColorSpace(colorSpace:ColorSpace): Promise<void>
+setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>
+
+Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result.
-Sets this window to the wide or default color gamut mode. This API uses a promise to return the result.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------------------------- | ---- | -------------- |
-| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.|
+| Name | Type | Mandatory | Description |
+| ------------------ | ------- | --------- | ------------------------------------------------------------ |
+| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed. The value **true** means to enable the full-screen mode for the window layout, and **false** means the opposite. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
-promise.then((data)=> {
- console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
+let isLayoutFullScreen = true;
+let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
+promise.then(()=> {
+ console.info('Succeeded in setting the window layout to full-screen mode.');
}).catch((err)=>{
- console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
});
```
-### getColorSpace8+
+### setSystemBarEnable(deprecated)
-getColorSpace(callback: AsyncCallback<ColorSpace>): void
+setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void
+
+Sets whether to display the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.
-Obtains the color gamut mode of this window. This API uses an asynchronous callback to return the result.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
-| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the result. When the color gamut mode is obtained successfully, `err` is `undefined`, and `data` is the current color gamut mode.|
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.getColorSpace((err, data) => {
+// In this example, the status bar and navigation bar are not displayed.
+let names = [];
+windowClass.setSystemBarEnable(names, (err) => {
if (err.code) {
- console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
+ console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
-})
+ console.info('Succeeded in setting the system bar to be invisible.');
+});
+
```
-### getColorSpace8+
+### setSystemBarEnable(deprecated)
-getColorSpace(): Promise<ColorSpace>
+setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>
-Obtains the color gamut mode of this window. This API uses a promise to return the result.
+Sets whether to display the status bar and navigation bar in this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowSystemBarEnable()](#setwindowsystembarenable9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ----- | --------- | ------------------------------------------------------------ |
+| names | Array | Yes | Whether to display the status bar and navigation bar.
For example, to display the status bar and navigation bar, set this parameter to **['status', 'navigation']**. By default, they are not displayed. |
+
**Return value**
-| Type | Description |
-| ---------------------------------------- | ------------------------------- |
-| Promise<[ColorSpace](#colorspace)> | Promise used to return the current color gamut mode.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let promise = windowClass.getColorSpace();
-promise.then((data)=> {
- console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
+// In this example, the status bar and navigation bar are not displayed.
+let names = [];
+let promise = windowClass.setSystemBarEnable(names);
+promise.then(()=> {
+ console.info('Succeeded in setting the system bar to be invisible.');
}).catch((err)=>{
- console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
});
+
```
-### setBackgroundColor
+### setSystemBarProperties(deprecated)
-setBackgroundColor(color: string, callback: AsyncCallback<void>): void
+setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void
+
+Sets the properties of the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result.
-Sets the background color for this window. This API uses an asynchronous callback to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9).
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarProperties()](#setwindowsystembarproperties9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
-| color | string | Yes | Background color to set. The value is a hexadecimal color code and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| ------------------- | ------------------------------------------- | --------- | ------------------------------------------------ |
+| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-let color = '#00ff33';
-windowClass.setBackgroundColor(color, (err, data) => {
+let SystemBarProperties={
+ statusBarColor: '#ff00ff',
+ navigationBarColor: '#00ff00',
+ // The following properties are supported since API version 8.
+ statusBarContentColor:'#ffffff',
+ navigationBarContentColor:'#00ffff'
+};
+windowClass.setSystemBarProperties(SystemBarProperties, (err) => {
if (err.code) {
- console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in setting the system bar properties.');
});
```
-### setBackgroundColor
+### setSystemBarProperties(deprecated)
-setBackgroundColor(color: string): Promise<void>
+setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void>
+
+Sets the properties of the status bar and navigation bar in this window. This API uses a promise to return the result.
-Sets the background color for this window. This API uses a promise to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9).
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowSystemBarProperties()](#setwindowsystembarproperties9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| color | string | Yes | Background color to set. The value is a hexadecimal color code and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
+| Name | Type | Mandatory | Description |
+| ------------------- | ------------------------------------------- | --------- | ------------------------------------------------ |
+| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let color = '#00ff33';
-let promise = windowClass.setBackgroundColor(color);
-promise.then((data)=> {
- console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
+let SystemBarProperties={
+ statusBarColor: '#ff00ff',
+ navigationBarColor: '#00ff00',
+ // The following properties are supported since API version 8.
+ statusBarContentColor:'#ffffff',
+ navigationBarContentColor:'#00ffff'
+};
+let promise = windowClass.setSystemBarProperties(SystemBarProperties);
+promise.then(()=> {
+ console.info('Succeeded in setting the system bar properties.');
}).catch((err)=>{
- console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
});
-```
-
-### setWakeUpScreen()9+
-
-setWakeUpScreen(wakeUp: boolean): void;
-
-Wakes up the screen.
-**System API**: This is a system API.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ---------------- | ------- | ---- | ---------------------------- |
-| wakeUp | boolean | Yes | Whether to wake up the screen.|
-
-**Example**
-
-```js
-let wakeUp = true;
-windowClass.setWakeUpScreen(wakeUp);
```
-### setBrightness
+### loadContent(deprecated)
-setBrightness(brightness: number, callback: AsyncCallback<void>): void
+loadContent(path: string, callback: AsyncCallback<void>): void
-Sets the screen brightness for this window. This API uses an asynchronous callback to return the result.
+Loads content from a page to this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setUIContent()](#setuicontent9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------------------------- | ---- | ------------------------------------ |
-| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ------------------------------------------------------- |
+| path | string | Yes | Path of the page from which the content will be loaded. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-let brightness = 1;
-windowClass.setBrightness(brightness, (err, data) => {
- if (err.code) {
- console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
+windowClass.loadContent('pages/page2/page2', (err) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content.');
});
+
```
-### setBrightness
+### loadContent(deprecated)
-setBrightness(brightness: number): Promise<void>
+loadContent(path: string): Promise<void>
-Sets the screen brightness for this window. This API uses a promise to return the result.
+Loads content from a page to this window. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setUIContent()](#setuicontent9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------ | ---- | ------------------------------------ |
-| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
+| Name | Type | Mandatory | Description |
+| ---- | ------ | --------- | ------------------------------------------------------- |
+| path | string | Yes | Path of the page from which the content will be loaded. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let brightness = 1;
-let promise = windowClass.setBrightness(brightness);
-promise.then((data)=> {
- console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
+let promise = windowClass.loadContent('pages/page2/page2');
+promise.then(()=> {
+ console.info('Succeeded in loading the content.');
}).catch((err)=>{
- console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
+ console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
});
+
```
-### setDimBehind(deprecated)
+### isShowing(deprecated)
-setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void
+isShowing(callback: AsyncCallback<boolean>): void
-Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result.
+Checks whether this window is displayed. This API uses an asynchronous callback to return the result.
> **NOTE**
>
-> This API cannot be used.
->
-> This API is supported since API version 7 and deprecated since API version 9.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isWindowShowing()](#iswindowshowing9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------------- | ------------------------- | ---- | -------------------------------------------------- |
-| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------- | --------- | ------------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means that the window is displayed, and **false** means the opposite. |
**Example**
```js
-windowClass.setDimBehind(0.5, (err, data) => {
+windowClass.isShowing((err, data) => {
if (err.code) {
- console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
+ console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
+ console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
});
```
-### setDimBehind(deprecated)
+### isShowing(deprecated)
-setDimBehind(dimBehindValue: number): Promise<void>
+isShowing(): Promise<boolean>
-Sets the dimness of the window that is not on top. This API uses a promise to return the result.
+Checks whether this window is displayed. This API uses a promise to return the result.
> **NOTE**
>
-> This API cannot be used.
->
-> This API is supported since API version 7 and deprecated since API version 9.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isWindowShowing()](#iswindowshowing9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------------- | ------ | ---- | -------------------------------------------------- |
-| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
-
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ---------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Promise used to return the result. The value **true** means that the window is displayed, and **false** means the opposite. |
**Example**
```js
-let promise = windowClass.setDimBehind(0.5);
+let promise = windowClass.isShowing();
promise.then((data)=> {
- console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
+ console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err));
});
```
-### setFocusable7+
+### on('systemAvoidAreaChange')(deprecated)
+
+on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void
-setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void
+Enables listening for changes to the area where the window cannot be displayed.
-Sets whether this window can gain focus. This API uses an asynchronous callback to return the result.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------------------------- | ---- | ---------------------------- |
-| isFocusable | boolean | Yes | Whether the window can gain focus.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | --------- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'systemAvoidAreaChange'**, indicating the event of changes to the area where the window cannot be displayed. |
+| callback | Callback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. |
**Example**
```js
-let isFocusable= true;
-windowClass.setFocusable(isFocusable, (err, data) => {
- if (err.code) {
- console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
+windowClass.on('systemAvoidAreaChange', (data) => {
+ console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
});
```
-### setFocusable7+
+### off('systemAvoidAreaChange')(deprecated)
-setFocusable(isFocusable: boolean): Promise<void>
+off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void
-Sets whether this window can gain focus. This API uses a promise to return the result.
+Disables listening for changes to the area where the window cannot be displayed.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------- | ---- | ---------------------------- |
-| isFocusable | boolean | Yes | Whether the window can gain focus.|
-
-**Return value**
-
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | --------- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'systemAvoidAreaChange'**, indicating the event of changes to the area where the window cannot be displayed. |
+| callback | Callback<[AvoidArea](#avoidarea7)> | No | Callback used to return the area. |
**Example**
```js
-let isFocusable= true;
-let promise = windowClass.setFocusable(isFocusable);
-promise.then((data)=> {
- console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
-}).catch((err)=>{
- console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
-});
+windowClass.off('systemAvoidAreaChange');
+
```
-### setKeepScreenOn
+### isSupportWideGamut(deprecated)
-setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void
+isSupportWideGamut(callback: AsyncCallback<boolean>): void
-Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result.
+Checks whether this window supports the wide-gamut color space. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isWindowSupportWideGamut()](#iswindowsupportwidegamut9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------------- | ------------------------- | ---- | ------------------------ |
-| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------- | --------- | ------------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite. |
**Example**
```js
-let isKeepScreenOn = true;
-windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
+windowClass.isSupportWideGamut((err, data) => {
if (err.code) {
- console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+ console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
-});
-```
+ console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
+})
-### setKeepScreenOn
+```
-setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>
+### isSupportWideGamut(deprecated)
-Sets whether to keep the screen always on. This API uses a promise to return the result.
+isSupportWideGamut(): Promise<boolean>
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+Checks whether this window supports the wide-gamut color space. This API uses a promise to return the result.
-**Parameters**
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1) instead.
-| Name | Type | Mandatory| Description |
-| -------------- | ------- | ---- | ------------------------ |
-| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.|
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ---------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Promise used to return the result. The value **true** means that the wide-gamut color space is supported, and **false** means the opposite. |
**Example**
```js
-let isKeepScreenOn = true;
-let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
-promise.then((data) => {
- console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
+let promise = windowClass.isSupportWideGamut();
+promise.then((data)=> {
+ console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{
- console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+ console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
});
+
```
-### setOutsideTouchable(deprecated)
+### setColorSpace(deprecated)
-setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void
+setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void
-Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result.
+Sets a color space for this window. This API uses an asynchronous callback to return the result.
> **NOTE**
>
-> This API cannot be used.
->
-> This API is supported since API version 7 and deprecated since API version 9.
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setWindowColorSpace()](#setwindowcolorspace9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ------------------------- | ---- | ---------------- |
-| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | --------- | ----------------------------------- |
+| colorSpace | [ColorSpace](#colorspace) | Yes | Color space to set. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.setOutsideTouchable(true, (err, data) => {
+windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
if (err.code) {
- console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in setting window colorspace.');
})
```
-### setOutsideTouchable(deprecated)
+### setColorSpace(deprecated)
-setOutsideTouchable(touchable: boolean): Promise<void>
+setColorSpace(colorSpace:ColorSpace): Promise<void>
-Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result.
+Sets a color space for this window. This API uses a promise to return the result.
> **NOTE**
>
-> This API cannot be used.
->
-> This API is supported since API version 7 and deprecated since API version 9.
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setWindowColorSpace()](#setwindowcolorspace9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ------- | ---- | ---------------- |
-| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.|
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | --------- | ------------------- |
+| colorSpace | [ColorSpace](#colorspace) | Yes | Color space to set. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let promise = windowClass.setOutsideTouchable(true);
-promise.then((data)=> {
- console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
+let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT);
+promise.then(()=> {
+ console.info('Succeeded in setting window colorspace.');
}).catch((err)=>{
- console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
});
+
```
-### setPrivacyMode7+
+### getColorSpace(deprecated)
-setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void
+getColorSpace(callback: AsyncCallback<ColorSpace>): void
-Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded.
+Obtains the color space of this window. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getWindowColorSpace()](#getwindowcolorspace9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------- | ---- | -------------------- |
-| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ |
+| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the result. When the color space is obtained successfully, **err** is **undefined**, and **data** is the current color space. |
**Example**
```js
-let isPrivacyMode = true;
-windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
+windowClass.getColorSpace((err, data) => {
if (err.code) {
- console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
+ console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));
+ console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
+})
-});
```
-### setPrivacyMode7+
-
-setPrivacyMode(isPrivacyMode: boolean): Promise<void>
+### getColorSpace(deprecated)
-Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded.
+getColorSpace(): Promise<ColorSpace>
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
+Obtains the color space of this window. This API uses a promise to return the result.
-**Parameters**
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getWindowColorSpace()](#getwindowcolorspace9) instead.
-| Name | Type | Mandatory| Description |
-| ------------- | ------- | ---- | -------------------- |
-| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.|
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ---------------------------------------- | ----------------------------------------------- |
+| Promise<[ColorSpace](#colorspace)> | Promise used to return the current color space. |
**Example**
```js
-let isPrivacyMode = true;
-let promise = windowClass.setPrivacyMode(isPrivacyMode);
+let promise = windowClass.getColorSpace();
promise.then((data)=> {
- console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
}).catch((err)=>{
- console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
+ console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
});
-```
-
-### setSnapshotSkip9+
-setSnapshotSkip(isSkip: boolean): void
-
-Sets whether to ignore this window during screen capturing or recording.
-
-**System API**: This is a system API.
-
-**System capability**: SystemCapability.WindowManager.WindowManager.Core
-
-**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------- | ---- | -------------------- |
-| isSkip | boolean | Yes | Whether to ignore the window. The default value is `false`.
The value `true` means that the window is ignored, and `false` means the opposite.
|
-```js
-let isSkip = true;
-windowClass.setSnapshotSkip(isSkip);
```
-### setTouchable7+
+### setBackgroundColor(deprecated)
-setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void
+setBackgroundColor(color: string, callback: AsyncCallback<void>): void
-Sets whether this window is touchable. This API uses an asynchronous callback to return the result.
+Sets the background color for this window. This API uses an asynchronous callback to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9) or [setUIContent()](#setuicontent9).
+
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBackgroundColor()](#setwindowbackgroundcolor9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------------------------- | ---- | -------------------- |
-| isTouchable | boolean | Yes | Whether the window is touchable.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| color | string | Yes | Background color to set. The value is a hexadecimal color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-let isTouchable = true;
-windowClass.setTouchable(isTouchable, (err, data) => {
+let color = '#00ff33';
+windowClass.setBackgroundColor(color, (err) => {
if (err.code) {
- console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
+ console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
-
+ console.info('Succeeded in setting the background color.');
});
```
-### setTouchable7+
+### setBackgroundColor(deprecated)
-setTouchable(isTouchable: boolean): Promise<void>
+setBackgroundColor(color: string): Promise<void>
-Sets whether this window is touchable. This API uses a promise to return the result.
+Sets the background color for this window. This API uses a promise to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9) or [setUIContent()](#setuicontent9).
+
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBackgroundColor()](#setwindowbackgroundcolor9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------- | ---- | -------------------- |
-| isTouchable | boolean | Yes | Whether the window is touchable.|
+| Name | Type | Mandatory | Description |
+| ----- | ------ | --------- | ------------------------------------------------------------ |
+| color | string | Yes | Background color to set. The value is a hexadecimal color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let isTouchable = true;
-let promise = windowClass.setTouchable(isTouchable);
-promise.then((data)=> {
- console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
+let color = '#00ff33';
+let promise = windowClass.setBackgroundColor(color);
+promise.then(()=> {
+ console.info('Succeeded in setting the background color.');
}).catch((err)=>{
- console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
});
+
```
-### setForbidSplitMove9+
+### setBrightness(deprecated)
-setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void
+setBrightness(brightness: number, callback: AsyncCallback<void>): void
-Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result.
+Sets the screen brightness for this window. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBrightness()](#setwindowbrightness9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------------------------- | ---- | -------------------- |
-| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-let isForbidSplitMove = true;
-windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => {
+let brightness = 1;
+windowClass.setBrightness(brightness, (err) => {
if (err.code) {
- console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
+ console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data));
-
+ console.info('Succeeded in setting the brightness.');
});
+
```
-### setForbidSplitMove9+
+### setBrightness(deprecated)
-setForbidSplitMove(isForbidSplitMove: boolean): Promise<void>
+setBrightness(brightness: number): Promise<void>
-Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result.
+Sets the screen brightness for this window. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowBrightness()](#setwindowbrightness9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------- | ---- | -------------------- |
-| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode.|
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | --------- | ------------------------------------------------------------ |
+| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let isForbidSplitMove = true;
-let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
-promise.then((data)=> {
- console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data));
+let brightness = 1;
+let promise = windowClass.setBrightness(brightness);
+promise.then(()=> {
+ console.info('Succeeded in setting the brightness.');
}).catch((err)=>{
- console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
+ console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
});
+
```
-### snapshot9+
+### setDimBehind(deprecated)
-snapshot(callback: AsyncCallback<image.PixelMap>): void
+setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void
-Captures this window. This API uses an asynchronous callback to return the result.
+Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result.
+
+> **NOTE**
+>
+> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------------------------- | ---- | -------------------- |
-| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.snapshot((err, data) => {
+windowClass.setDimBehind(0.5, (err) => {
if (err.code) {
- console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
+ console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
- data.release(); // Release the memory in time after the PixelMap is used.
+ console.info('Succeeded in setting the dimness.');
});
```
-### snapshot9+
+### setDimBehind(deprecated)
-snapshot(): Promise<image.PixelMap>
+setDimBehind(dimBehindValue: number): Promise<void>
-Captures this window. This API uses a promise to return the result.
+Sets the dimness of the window that is not on top. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | --------- | ------------------------------------------------------------ |
+| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest. |
+
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise used to return the window screenshot.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let promise = windowClass.snapshot();
-promise.then((pixelMap)=> {
- console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
- pixelMap.release(); // Release the memory in time after the PixelMap is used.
+let promise = windowClass.setDimBehind(0.5);
+promise.then(()=> {
+ console.info('Succeeded in setting the dimness.');
}).catch((err)=>{
- console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
+ console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
});
+
```
-### setBlur9+
+### setFocusable(deprecated)
-setBlur(radius: number): void
+setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void
-Blurs this window.
+Sets whether this window can gain focus. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowFocusable()](#setwindowfocusable9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| radius | number | Yes | Radius of the blur. The value is greater than or equal to 0. The value `0` means that the blur is disabled for the window.|
+| Name | Type | Mandatory | Description |
+| ----------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| isFocusable | boolean | Yes | Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.setBlur(4.0);
+let isFocusable= true;
+windowClass.setFocusable(isFocusable, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window to be focusable.');
+});
+
```
-### setBackdropBlur9+
+### setFocusable(deprecated)
-setBackdropBlur(radius: number): void
+setFocusable(isFocusable: boolean): Promise<void>
-Blurs the background of this window.
+Sets whether this window can gain focus. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowFocusable()](#setwindowfocusable9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| radius | number | Yes | Radius of the blur. The value is greater than or equal to 0. The value `0` means that the blur is disabled for the background of the window.|
+| Name | Type | Mandatory | Description |
+| ----------- | ------- | --------- | ------------------------------------------------------------ |
+| isFocusable | boolean | Yes | Whether the window can gain focus. The value **true** means that the window can gain focus, and **false** means the opposite. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-windowClass.setBackdropBlur(4.0);
+let isFocusable= true;
+let promise = windowClass.setFocusable(isFocusable);
+promise.then(()=> {
+ console.info('Succeeded in setting the window to be focusable.');
+}).catch((err)=>{
+ console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
+});
```
-### setBackdropBlurStyle9+
+### setKeepScreenOn(deprecated)
-setBackdropBlurStyle(blurStyle: BlurStyle): void
+setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void
-Sets the blur style for the background of this window.
+Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowKeepScreenOn()](#setwindowkeepscreenon9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | --------- | ---- | ---------------------- |
-| blurStyle | [BlurStyle](#blurstyle9) | Yes | Blur style to set for the background of the window.|
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.setBackdropBlurStyle(window.BlurType.THIN);
+let isKeepScreenOn = true;
+windowClass.setKeepScreenOn(isKeepScreenOn, (err) => {
+ if (err.code) {
+ console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the screen to be always on.');
+});
```
-### setShadow9+
+### setKeepScreenOn(deprecated)
-setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
+setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>
-Sets the shadow for the window borders.
+Sets whether to keep the screen always on. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [setWindowKeepScreenOn()](#setwindowkeepscreenon9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------ | ---- | ------------------------------------------------------------ |
-| radius | number | Yes | Radius of the shadow. The value is greater than or equal to 0. The value `0` means that the shadow is disabled for the window borders.|
-| color | string | No | Color of the shadow. The value is a hexadecimal color code and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
-| offsetX | number | No | Offset of the shadow along the x-axis, in pixels. |
-| offsetY | number | No | Offset of the shadow along the y-axis, in pixels. |
+| Name | Type | Mandatory | Description |
+| -------------- | ------- | --------- | ------------------------------------------------------------ |
+| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on. The value **true** means to keep the screen always on, and **false** means the opposite. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
+let isKeepScreenOn = true;
+let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
+promise.then(() => {
+ console.info('Succeeded in setting the screen to be always on.');
+}).catch((err)=>{
+ console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+});
```
-### setCornerRadius9+
+### setOutsideTouchable(deprecated)
-setCornerRadius(cornerRadius: number): void
+setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void
-Sets the radius of the rounded corners for this window.
+Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------- | ---- | -------------------- |
-| radius | number | Yes | Radius of the rounded corners. The value is greater than or equal to 0. The value `0` means that the window does not use rounded corners.|
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means the area outside the subwindow is touchable, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-windowClass.setCornerRadius(4.0);
+windowClass.setOutsideTouchable(true, (err) => {
+ if (err.code) {
+ console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the area to be touchable.');
+})
```
-### opacity9+
+### setOutsideTouchable(deprecated)
-opacity(opacity: number): void
+setOutsideTouchable(touchable: boolean): Promise<void>
-Sets the opacity for this window.
+Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API cannot be used. This API is supported since API version 7 and deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------ | ---- | --------------------- |
-| opacity | number | Yes | Opacity to set. The value ranges from 0.0 to 1.0.|
+| Name | Type | Mandatory | Description |
+| --------- | ------- | --------- | ------------------------------------------------------------ |
+| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means the area outside the subwindow is touchable, and **false** means the opposite. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-windowClass.opacity(0.5);
+let promise = windowClass.setOutsideTouchable(true);
+promise.then(()=> {
+ console.info('Succeeded in setting the area to be touchable.');
+}).catch((err)=>{
+ console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
+});
```
-### scale9+
+### setPrivacyMode(deprecated)
-scale(scaleOptions: ScaleOptions): void
+setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void
-Sets the scale parameters for this window.
+Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowPrivacyMode()](#setwindowprivacymode9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------ | ------------------------------ | ---- | ---------- |
-| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes | Scale parameters to set.|
+| Name | Type | Mandatory | Description |
+| ------------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-let obj : window.ScaleOptions = {
- x : 2.0,
- y : 1.0,
- pivotX = 0.5;
- pivotY = 0.5;
-}
-windowClass.scale(obj);
+let isPrivacyMode = true;
+windowClass.setPrivacyMode(isPrivacyMode, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window to privacy mode.');
+
+});
+
```
-### rotate9+
+### setPrivacyMode(deprecated)
-rotate(rotateOptions: RotateOptions): void
+setPrivacyMode(isPrivacyMode: boolean): Promise<void>
-Sets the rotation parameters for this window.
+Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowPrivacyMode()](#setwindowprivacymode9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | -------------------------------- | ---- | ---------- |
-| rotateOptions | [RotateOptions](#rotateoptions9) | Yes | Rotation parameters to set.|
+| Name | Type | Mandatory | Description |
+| ------------- | ------- | --------- | ------------------------------------------------------------ |
+| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode. The value **true** means that the window is in privacy mode, and **false** means the opposite. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let obj : window.RotateOptions = {
- x : 1.0,
- y : 1.0,
- z : 45.0,
- pivotX = 0.5;
- pivotY = 0.5;
-}
-windowClass.rotate(obj);
+let isPrivacyMode = true;
+let promise = windowClass.setPrivacyMode(isPrivacyMode);
+promise.then(()=> {
+ console.info('Succeeded in setting the window to privacy mode.');
+}).catch((err)=>{
+ console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
+});
```
-### translate9+
+### setTouchable(deprecated)
-translate(translateOptions: TranslateOptions): void
+setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void
-Sets the translation parameters for this window.
+Sets whether this window is touchable. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowTouchable()](#setwindowtouchable9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------------- | -------------------------------------- | ---- | ---------- |
-| translateOptions | [TranslateOptions](#translateoptions9) | Yes | Translation parameters to set.|
+| Name | Type | Mandatory | Description |
+| ----------- | ------------------------- | --------- | ------------------------------------------------------------ |
+| isTouchable | boolean | Yes | Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
```js
-let obj : window.TranslateOptions = {
- x : 100.0,
- y : 0.0,
- z : 0.0
-}
-windowClass.translate(obj);
+let isTouchable = true;
+windowClass.setTouchable(isTouchable, (err) => {
+ if (err.code) {
+ console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the window to be touchable.');
+
+});
```
-### getTransitionController9+
+### setTouchable(deprecated)
- getTransitionController(): TransitionController
+setTouchable(isTouchable: boolean): Promise<void>
-Obtains the transition animation controller.
+Sets whether this window is touchable. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setWindowTouchable()](#setwindowtouchable9-1) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----------- | ------- | --------- | ------------------------------------------------------------ |
+| isTouchable | boolean | Yes | Whether the window is touchable. The value **true** means that the window is touchable, and **false** means the opposite. |
+
**Return value**
-| Type | Description |
-| ---------------------------------------------- | ---------------- |
-| [TransitionController](#transitioncontroller9) | Transition animation controller.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
**Example**
```js
-let controller = windowClass.getTransitionController(); // Obtain the transition animation controller.
-controller.animationForHidden = (context : window.TransitionContext) => {
- let toWindow = context.toWindow
- animateTo({
- duration: 1000, // Animation duration.
- tempo: 0.5, // Playback speed.
- curve: Curve.EaseInOut, // Animation curve.
- delay: 0, // Animation delay.
- iterations: 1, // Number of playback times.
- playMode: PlayMode.Normal // Animation playback mode.
- onFinish: ()=> {
- context.completeTransition(true)
- }
- }, () => {
- let obj : window.TranslateOptions = {
- x : 100.0,
- y : 0.0,
- z : 0.0
- }
- toWindow.translate(obj); // Set the transition animation.
- console.info('toWindow translate end');
- }
- )
- console.info('complete transition end');
-}
-windowClass.hideWithAnimation((err, data) => {
- if (err.code) {
- console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
-})
+let isTouchable = true;
+let promise = windowClass.setTouchable(isTouchable);
+promise.then(()=> {
+ console.info('Succeeded in setting the window to be touchable.');
+}).catch((err)=>{
+ console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
+});
```
## WindowStageEventType9+
@@ -3459,18 +5849,18 @@ Describes the lifecycle of a window stage.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-| Name | Default Value | Description |
-| ---------- | ------ | ---------- |
-| FOREGROUND | 1 | The window stage is running in the foreground.|
-| ACTIVE | 2 | The window stage gains focus.|
-| INACTIVE | 3 | The window stage loses focus.|
-| BACKGROUND | 4 | The window stage is running in the background.|
+| Name | Default Value | Description |
+| ---------- | ------------- | ---------------------------------------------- |
+| FOREGROUND | 1 | The window stage is running in the foreground. |
+| ACTIVE | 2 | The window stage gains focus. |
+| INACTIVE | 3 | The window stage loses focus. |
+| BACKGROUND | 4 | The window stage is running in the background. |
## WindowStage9+
Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.
-Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a `WindowStage` instance.
+Before calling any of the following APIs, you must use [onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate) to create a **WindowStage** instance.
### getMainWindow9+
@@ -3484,9 +5874,18 @@ Obtains the main window of this window stage. This API uses an asynchronous call
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | --------------------------------------------- |
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.|
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------------- | --------- | ---------------------------------------- |
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3507,6 +5906,7 @@ class myAbility extends Ability {
}
}
```
+
### getMainWindow9+
getMainWindow(): Promise<Window>
@@ -3519,9 +5919,18 @@ Obtains the main window of this window stage. This API uses a promise to return
**Return value**
-| Type | Description |
-| -------------------------------- | ------------------------------------------------ |
-| Promise<[Window](#window)> | Promise used to return the main window.|
+| Type | Description |
+| -------------------------------- | --------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the main window. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3541,6 +5950,48 @@ class myAbility extends Ability {
}
}
```
+
+### getMainWindowSync9+
+
+getMainWindowSync(): Window
+
+Obtains the main window of this window stage.
+
+**Model restriction**: This API can be used only in the stage model.
+
+**System capability**: SystemCapability.WindowManager.WindowManager.Core
+
+**Return value**
+
+| Type | Description |
+| ----------------- | ----------------------- |
+| [Window](#window) | return the main window. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
+
+**Example**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ try {
+ let windowClass = windowStage.getMainWindowSync();
+ } catch (exception) {
+ console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
+ };
+ }
+}
+```
+
### createSubWindow9+
createSubWindow(name: string, callback: AsyncCallback<Window>): void
@@ -3553,10 +6004,19 @@ Creates a subwindow for this window stage. This API uses an asynchronous callbac
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------------- | ---- | --------------------------------------------- |
-| name | String | Yes | Name of the subwindow. |
-| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow.|
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------------- | --------- | -------------------------------------- |
+| name | String | Yes | Name of the subwindow. |
+| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3566,18 +6026,23 @@ class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
- windowStage.createSubWindow('mySubWindow', (err, data) => {
- if (err.code) {
- console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
- windowClass.resetSize(500, 1000);
- });
+ try {
+ windowStage.createSubWindow('mySubWindow', (err, data) => {
+ if (err.code) {
+ console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ windowClass = data;
+ console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
+ windowClass.resetSize(500, 1000);
+ });
+ } catch (exception) {
+ console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
+ };
}
}
```
+
### createSubWindow9+
createSubWindow(name: string): Promise<Window>
@@ -3590,15 +6055,24 @@ Creates a subwindow for this window stage. This API uses a promise to return the
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | -------------- |
-| name | String | Yes | Name of the subwindow.|
+| Name | Type | Mandatory | Description |
+| ---- | ------ | --------- | ---------------------- |
+| name | String | Yes | Name of the subwindow. |
**Return value**
-| Type | Description |
-| -------------------------------- | ------------------------------------------------ |
-| Promise<[Window](#window)> | Promise used to return the subwindow.|
+| Type | Description |
+| -------------------------------- | ------------------------------------- |
+| Promise<[Window](#window)> | Promise used to return the subwindow. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3608,16 +6082,21 @@ class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
- let promise = windowStage.createSubWindow('mySubWindow');
- promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
- }).catch((err)=>{
- console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
- })
+ try {
+ let promise = windowStage.createSubWindow('mySubWindow');
+ promise.then((data)=> {
+ windowClass = data;
+ console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
+ });
+ } catch (exception) {
+ console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
+ };
}
}
```
+
### getSubWindow9+
getSubWindow(callback: AsyncCallback<Array<Window>>): void
@@ -3630,9 +6109,17 @@ Obtains all the subwindows of this window stage. This API uses an asynchronous c
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
-| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------------------------------- | --------- | ------------------------------------------- |
+| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3653,6 +6140,7 @@ class myAbility extends Ability {
}
}
```
+
### getSubWindow9+
getSubWindow(): Promise<Array<Window>>
@@ -3665,9 +6153,17 @@ Obtains all the subwindows of this window stage. This API uses a promise to retu
**Return value**
-| Type | Description |
-| --------------------------------------------- | ---------------------------------------------------- |
-| Promise<Array<[Window](#window)>> | Promise used to return all the subwindows.|
+| Type | Description |
+| --------------------------------------------- | ------------------------------------------ |
+| Promise<Array<[Window](#window)>> | Promise used to return all the subwindows. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3687,6 +6183,7 @@ class myAbility extends Ability {
}
}
```
+
### loadContent9+
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void
@@ -3699,11 +6196,20 @@ Loads content from a page associated with a local storage to the main window in
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
-| path | string | Yes | Path of the page from which the content will be loaded. |
-| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
+| path | string | Yes | Path of the page from which the content will be loaded. |
+| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3715,13 +6221,17 @@ class myAbility extends Ability {
this.storage = new LocalStorage();
this.storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate');
- windowStage.loadContent('pages/page2',this.storage,(err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
- });
+ try {
+ windowStage.loadContent('pages/page2',this.storage,(err) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content.');
+ });
+ } catch (exception) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
+ };
}
}
```
@@ -3738,16 +6248,25 @@ Loads content from a page associated with a local storage to the main window in
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
-| path | string | Yes | Path of the page from which the content will be loaded. |
-| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
+| Name | Type | Mandatory | Description |
+| ------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
+| path | string | Yes | Path of the page from which the content will be loaded. |
+| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
+| Type | Description |
+| ------------------- | ------------------------------ |
+| Promise<void> | Promise that returns no value. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3759,14 +6278,16 @@ class myAbility extends Ability {
this.storage = new LocalStorage();
this.storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate');
- let windowClass = null;
- let promise = windowStage.loadContent('pages/page2',this.storage);
- promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
- }).catch((err)=>{
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- })
+ try {
+ let promise = windowStage.loadContent('pages/page2',this.storage);
+ promise.then(()=> {
+ console.info('Succeeded in loading the content.');
+ }).catch((err)=>{
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ });
+ } catch (exception) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
+ };
}
}
```
@@ -3783,10 +6304,19 @@ Loads content from a page to this window stage. This API uses an asynchronous ca
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------- | ---- | -------------------- |
-| path | string | Yes | Path of the page from which the content will be loaded.|
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | --------- | ------------------------------------------------------- |
+| path | string | Yes | Path of the page from which the content will be loaded. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3795,13 +6325,17 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
- windowStage.loadContent('pages/page2', (err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
- });
+ try {
+ windowStage.loadContent('pages/page2', (err) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content.');
+ });
+ } catch (exception) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
+ };
}
}
```
@@ -3818,10 +6352,19 @@ Enables listening for window stage lifecycle changes.
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
-| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the window stage lifecycle state. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'windowStageEvent'**, indicating the window stage lifecycle change event. |
+| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the window stage lifecycle state. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3830,9 +6373,15 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
- windowStage.on('windowStageEvent', (data) => {
- console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
- });
+ try {
+ windowStage.on('windowStageEvent', (data) => {
+ console.info('Succeeded in enabling the listener for window stage event changes. Data: ' +
+ JSON.stringify(data));
+ });
+ } catch (exception) {
+ console.error('Failed to enable the listener for window stage event changes. Cause:' +
+ JSON.stringify(exception));
+ };
}
}
```
@@ -3849,10 +6398,19 @@ Disables listening for window stage lifecycle changes.
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
-| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the window stage lifecycle state. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'windowStageEvent'**, indicating the window stage lifecycle change event. |
+| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the window stage lifecycle state. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3861,7 +6419,12 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
- windowStage.off('windowStageEvent');
+ try {
+ windowStage.off('windowStageEvent');
+ } catch (exception) {
+ console.error('Failed to disable the listener for window stage event changes. Cause:' +
+ JSON.stringify(exception));
+ };
}
}
```
@@ -3878,6 +6441,15 @@ Disables window decorators.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
+
**Example**
```ts
@@ -3904,9 +6476,18 @@ Sets whether to display the window of the application on the lock screen.
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------------- | ------- | ---- | ---------------------------- |
-| showOnLockScreen | boolean | Yes | Whether to display the window on the lock screen.|
+| Name | Type | Mandatory | Description |
+| ---------------- | ------- | --------- | ------------------------------------------------------------ |
+| showOnLockScreen | boolean | Yes | Whether to display the window on the lock screen. The value **true** means to display the window on the lock screen, and **false** means the opposite. |
+
+**Error codes**
+
+For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 1300002 | This window state is abnormal. |
+| 1300005 | This window stage is abnormal. |
**Example**
@@ -3915,10 +6496,15 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
- windowStage.setShowOnLockScreen(true);
+ try {
+ windowStage.setShowOnLockScreen(true);
+ } catch (exception) {
+ console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
+ };
}
}
```
+
## TransitionContext9+
Provides the context for the transition animation.
@@ -3929,9 +6515,9 @@ Provides the context for the transition animation.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-| Name | Type | Readable| Writable| Description |
-| --------------------- | ----------------- | ---- | ---- | ---------------- |
-| toWindow9+ | [Window](#window) | Yes | Yes | Target window to display the animation.|
+| Name | Type | Readable | Writable | Description |
+| --------------------- | ----------------- | -------- | -------- | --------------------------------------- |
+| toWindow9+ | [Window](#window) | Yes | Yes | Target window to display the animation. |
### completeTransition9+
@@ -3945,16 +6531,16 @@ Completes the transition. This API can be called only after [animateTo()](../ark
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ------- | ---- | ------------------------------------------------------------ |
-| isCompleted | boolean | Yes | Whether the transition is complete. The value `true` means that the transition is complete, and `false` means the opposite.|
+| Name | Type | Mandatory | Description |
+| ----------- | ------- | --------- | ------------------------------------------------------------ |
+| isCompleted | boolean | Yes | Whether the transition is complete. The value **true** means that the transition is complete, and **false** means the opposite. |
**Example**
```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
- let toWindow = context.toWindow
+ let toWindow = context.toWindow;
animateTo({
duration: 1000, // Animation duration.
tempo: 0.5, // Playback speed.
@@ -3967,14 +6553,18 @@ controller.animationForShown = (context : window.TransitionContext) => {
x : 100.0,
y : 0.0,
z : 0.0
- }
+ };
toWindow.translate(obj);
console.info('toWindow translate end');
}
)
- context.completeTransition(true)
+ try {
+ context.completeTransition(true)
+ } catch (exception) {
+ console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception));
+ }
console.info('complete transition end');
-}
+};
```
## TransitionController9+
@@ -3993,16 +6583,16 @@ Customizes the animation for the scenario when the window is shown.
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ---------------------------------------- | ---- | -------------------- |
-| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.|
+| Name | Type | Mandatory | Description |
+| ------- | ---------------------------------------- | --------- | ------------------------------------ |
+| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation. |
**Example**
```js
let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => {
- let toWindow = context.toWindow
+ let toWindow = context.toWindow;
animateTo({
duration: 1000, // Animation duration.
tempo: 0.5, // Playback speed.
@@ -4018,7 +6608,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
x : 100.0,
y : 0.0,
z : 0.0
- }
+ };
toWindow.translate(obj);
console.info('toWindow translate end');
}
@@ -4039,16 +6629,16 @@ Customizes the animation for the scenario when the window is hidden.
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ---------------------------------------- | ---- | -------------------- |
-| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.|
+| Name | Type | Mandatory | Description |
+| ------- | ---------------------------------------- | --------- | ------------------------------------ |
+| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation. |
**Example**
```js
let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => {
- let toWindow = context.toWindow
+ let toWindow = context.toWindow;
animateTo({
duration: 1000, // Animation duration.
tempo: 0.5, // Playback speed.
@@ -4064,7 +6654,7 @@ controller.animationForHidden = (context : window.TransitionContext) => {
x : 100.0,
y : 0.0,
z : 0.0
- }
+ };
toWindow.translate(obj);
console.info('toWindow translate end');
}
@@ -4072,3 +6662,4 @@ controller.animationForHidden = (context : window.TransitionContext) => {
console.info('complete transition end');
}
```
+
diff --git a/en/application-dev/reference/errorcodes/errorcode-display.md b/en/application-dev/reference/errorcodes/errorcode-display.md
new file mode 100644
index 0000000000000000000000000000000000000000..f86b0b10736c407cefb288e317288c66a9fd5a07
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-display.md
@@ -0,0 +1,43 @@
+# Display Error Codes
+
+## 1400001 Invalid Display or Screen
+**Error Message**
+Invalid display or screen.
+
+**Description**
+This error code is reported when an invalid display, including a virtual screen, is operated.
+
+**Possible Causes**
+1. The virtual screen has not been created.
+2. The virtual screen has been destroyed.
+
+**Procedure**
+1. Before operating the virtual screen, check whether the virtual screen has been created.
+2. Check whether the virtual screen has been destroyed.
+
+## 1400002 Unauthorized Operation
+**Error Message**
+Unauthorized operation.
+
+**Description**
+This error code is reported when the API does not have the required permissions to operate an object.
+
+**Possible Causes**
+The virtual screen object of another process is operated.
+
+**Procedure**
+Check whether unauthorized operations are performed on the object of another process. If yes, delete the operations.
+
+## 1400003 Abnormal Display Manager Service
+**Error Message**
+This display manager service works abnormally.
+
+**Description**
+This error code is reported when the display manager service is abnormal.
+
+**Possible Causes**
+1. The display manager service is not started normally.
+2. The bottom-layer graphics synthesis and rendering are abnormal.
+
+**Procedure**
+Try again later or restart the device.
diff --git a/en/application-dev/reference/errorcodes/errorcode-window.md b/en/application-dev/reference/errorcodes/errorcode-window.md
new file mode 100644
index 0000000000000000000000000000000000000000..9e61c92b592c2e155ac6757f8e1dee4a01d762e9
--- /dev/null
+++ b/en/application-dev/reference/errorcodes/errorcode-window.md
@@ -0,0 +1,79 @@
+# Window Error Codes
+
+## 1300001 Repeated Operation
+**Error Message**
+Repeated operation.
+
+**Description**
+This error code is reported when a repeated operation is performed.
+
+**Possible Causes**
+The window to create already exists.
+
+**Procedure**
+Before creating a window, check whether the window already exists. If it already exists, use it directly.
+
+## 1300002 Abnormal Window State
+**Error Message**
+This window state is abnormal.
+
+**Description**
+This error code is reported when you operate a window in an abnormal state, for example, a window that has been destroyed.
+
+**Possible Causes**
+The window has been destroyed when being operated.
+
+**Procedure**
+Before operating the window, check whether it exists.
+
+## 1300003 Abnormal Window Manager Service
+**Error Message**
+This window manager service works abnormally.
+
+**Description**
+This error code is reported when the window manager service is abnormal.
+
+**Possible Causes**
+The internal services of the window are not started normally.
+
+**Procedure**
+Try again later or restart the device.
+
+## 1300004 Unauthorized Operation
+**Error Message**
+Unauthorized operation.
+
+**Description**
+This error code is reported when the API does not have the required permissions to operate an object.
+
+**Possible Causes**
+The window object of another process is operated.
+
+**Procedure**
+Check whether unauthorized operations are performed on the object of another process. If yes, delete the operations.
+
+## 1300005 Abnormal Window Stage
+**Error Message**
+This window stage is abnormal.
+
+**Description**
+This error code is reported when you operate a window stage in the abnormal state, for example, a window stage that has been destroyed.
+
+**Possible Causes**
+The window stage has been destroyed when being operated.
+
+**Procedure**
+Before operating a window stage, check whether it exists.
+
+## 1300006 Abnormal Window Context
+**Error Message**
+This window context is abnormal.
+
+**Description**
+This error code is reported when you operate a window context in the abnormal state, for example, a window context that has been destroyed.
+
+**Possible Causes**
+The window context has been destroyed when being operated.
+
+**Procedure**
+Before operating the window context, check whether it exists.