diff --git a/en/application-dev/ability/context-userguide.md b/en/application-dev/ability/context-userguide.md
index d5cd52e64ed5064ded90efea7d60898e1c2ee96c..17fd6b5eb780f656ada33e94a6d1584ebbc55e5c 100644
--- a/en/application-dev/ability/context-userguide.md
+++ b/en/application-dev/ability/context-userguide.md
@@ -96,13 +96,13 @@ Obtain the context by calling **context.getApplicationContext()** in **Ability**
**Example**
```javascript
-import AbilityStage from "@ohos.application.AbilityStage";
+import Ability from "@ohos.application.Ability";
var lifecycleid;
-export default class MyAbilityStage extends AbilityStage {
+export default class MainAbility extends Ability {
onCreate() {
- console.log("MyAbilityStage onCreate")
+ console.log("MainAbility onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
@@ -141,11 +141,11 @@ export default class MyAbilityStage extends AbilityStage {
// 2. Use applicationContext to register and listen for the ability lifecycle in the application.
lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
- }
+ },
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
- console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
+ console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
}
@@ -211,7 +211,13 @@ export default class MainAbility extends Ability {
let context = this.context;
console.log("[Demo] MainAbility bundleName " + context.abilityInfo.bundleName)
- windowStage.setUIContent(this.context, "pages/index", null)
+ windowStage.loadContent("pages/index", (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))
+ });
}
onWindowStageDestroy() {
@@ -237,7 +243,7 @@ For details, see [FormExtensionContext](../reference/apis/js-apis-formextensionc
### Obtaining the Context on an ArkTS Page
-In the stage model, in the `onWindowStageCreate` lifecycle of an ability, you can call `SetUIContent` of `WindowStage` to load an ArkTS page. In some scenarios, you need to obtain the context on the page to call related APIs.
+In the stage model, in the onWindowStageCreate lifecycle of an ability, you can call **SetUIContent** of **WindowStage** to load an ArkTS page. In some scenarios, you need to obtain the context on the page to call related APIs.
**How to Obtain**
@@ -245,7 +251,7 @@ Use the API described in the table below to obtain the context associated with a
| API | Description |
| :------------------------------------ | :--------------------------- |
-| getContext(component: Object): Object | Obtains the `Context` object associated with a component on the page.|
+| getContext(component: Object): Object | Obtains the **Context** object associated with a component on the page.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md
index 2887044269488b47e2a4f434447b43d617a16f05..d77a386562bb6af94a38edfbd6574647bb93d91d 100644
--- a/en/application-dev/reference/apis/js-apis-medialibrary.md
+++ b/en/application-dev/reference/apis/js-apis-medialibrary.md
@@ -46,6 +46,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
let media = mediaLibrary.getMediaLibrary(context);
```
+
## mediaLibrary.getMediaLibrary
getMediaLibrary(): MediaLibrary
@@ -54,10 +55,6 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the FA model.
-> **NOTE**
->
-> This API is no longer maintained since API version 8. You are advised to use [mediaLibrary.getMediaLibrary8+](#medialibrarygetmedialibrary8) instead.
-
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Return value**
@@ -206,8 +203,8 @@ Subscribes to the media library changes. This API uses an asynchronous callback
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ---------------------------------------- |
-| type | string | Yes | Media type.
'deviceChange': registered device change
'albumChange': album change
'imageChange': image file change
'audioChange': audio file change
'videoChange': video file change
'fileChange': file change
'remoteFileChange': file change on the registered device|
-| callback | callback<void> | Yes | Void callback. |
+| type | 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange' | Yes | Media type.
'deviceChange': registered device change
'albumChange': album change
'imageChange': image file change
'audioChange': audio file change
'videoChange': video file change
'fileChange': file change
'remoteFileChange': file change on the registered device|
+| callback | Callback<void> | Yes | Void callback. |
**Example**
@@ -228,8 +225,8 @@ Unsubscribes from the media library changes. This API uses an asynchronous callb
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ---------------------------------------- |
-| type | string | Yes | Media type.
'deviceChange': registered device change
'albumChange': album change
'imageChange': image file change
'audioChange': audio file change
'videoChange': video file change
'fileChange': file change
'remoteFileChange': file change on the registered device|
-| callback | callback<void> | No | Void callback. |
+| type | 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange' | Yes | Media type.
'deviceChange': registered device change
'albumChange': album change
'imageChange': image file change
'audioChange': audio file change
'videoChange': video file change
'fileChange': file change
'remoteFileChange': file change on the registered device|
+| callback | Callback<void> | No | Void callback. |
**Example**
@@ -303,12 +300,17 @@ Creates a media asset. This API uses a promise to return the result.
**Example**
```js
-let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
-media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){
- console.info("getPublicDirectory successfully:"+ JSON.stringify(dicResult));
-}).catch(function(err){
- console.info("getPublicDirectory failed with error:"+ err);
-});
+async function example() {
+ // Create an image file in promise mode.
+ let mediaType = mediaLibrary.MediaType.IMAGE;
+ let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
+ const path = await media.getPublicDirectory(DIR_IMAGE);
+ media.createAsset(mediaType, 'imagePromise.jpg', path + 'myPicture/').then((fileAsset) => {
+ console.info('createAsset successfully, message = ' + JSON.stringify(fileAsset));
+ }).catch((err) => {
+ console.info('createAsset failed, message = ' + err);
+ });
+}
```
### deleteAsset8+
@@ -344,8 +346,6 @@ async function example() {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [fileType.toString()],
};
- const context = getContext(this);
- var media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
let asset = await fetchFileResult.getFirstObject();
if (asset == undefined) {
@@ -388,8 +388,6 @@ async function example() {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [fileType.toString()],
};
- const context = getContext(this);
- var media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
let asset = await fetchFileResult.getFirstObject();
if (asset == undefined) {
@@ -557,7 +555,6 @@ Call this API when you no longer need to use the APIs in the **MediaLibrary** in
**Example**
```js
-var media = mediaLibrary.getMediaLibrary(context);
media.release((err) => {
// do something
});
@@ -667,7 +664,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => {
startImagePreview(images: Array<string>, index: number, callback: AsyncCallback<void>): void
-Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **dataability://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
+Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
> **NOTE**
>
@@ -679,7 +676,7 @@ Starts image preview, with the first image to preview specified. This API can be
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
-| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **dataability://** or **https://**.|
+| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **datashare://**.|
| index | number | Yes | Index of the first image to preview. |
| callback | AsyncCallback<void> | Yes | Callback used to return the image preview result. If the preview fails, an error message is returned. |
@@ -687,8 +684,8 @@ Starts image preview, with the first image to preview specified. This API can be
```js
let images = [
- "dataability:///media/xxxx/2",
- "dataability:///media/xxxx/3"
+ "datashare:///media/xxxx/2",
+ "datashare:///media/xxxx/3"
];
/* Preview online images.
let images = [
@@ -711,7 +708,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => {
startImagePreview(images: Array<string>, callback: AsyncCallback<void>): void
-Starts image preview. This API can be used to preview local images whose URIs start with **dataability://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
+Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
> **NOTE**
>
@@ -723,15 +720,15 @@ Starts image preview. This API can be used to preview local images whose URIs st
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
-| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **dataability://**.|
+| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **datashare://**.|
| callback | AsyncCallback<void> | Yes | Callback used to return the image preview result. If the preview fails, an error message is returned. |
**Example**
```js
let images = [
- "dataability:///media/xxxx/2",
- "dataability:///media/xxxx/3"
+ "datashare:///media/xxxx/2",
+ "datashare:///media/xxxx/3"
];
/* Preview online images.
let images = [
@@ -753,7 +750,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => {
startImagePreview(images: Array<string>, index?: number): Promise<void>
-Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with dataability:// or online images whose URIs start with https://. It uses a promise to return the execution result.
+Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
> **NOTE**
>
@@ -765,7 +762,7 @@ Starts image preview, with the first image to preview specified. This API can be
| Name | Type | Mandatory | Description |
| ------ | ------------------- | ---- | ---------------------------------------- |
-| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **dataability://** or **https://**.|
+| images | Array<string> | Yes | URIs of the images to preview. The value can start with either **https://** or **datashare://**.|
| index | number | No | Index of the first image to preview. If this parameter is not specified, the default value **0** is used. |
**Return value**
@@ -778,8 +775,8 @@ Starts image preview, with the first image to preview specified. This API can be
```js
let images = [
- "dataability:///media/xxxx/2",
- "dataability:///media/xxxx/3"
+ "datashare:///media/xxxx/2",
+ "datashare:///media/xxxx/3"
];
/* Preview online images.
let images = [
@@ -813,7 +810,7 @@ Starts media selection. This API uses an asynchronous callback to return the lis
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------------ |
| option | [MediaSelectOption](#mediaselectoptiondeprecated) | Yes | Media selection option. |
-| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the list of URIs (starting with **dataability://**) that store the selected media assets.|
+| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the list of URIs (starting with **datashare://**) that store the selected media assets.|
**Example**
@@ -855,7 +852,7 @@ Starts media selection. This API uses a promise to return the list of URIs that
| Type | Description |
| ---------------------------------- | ---------------------------------------- |
-| Promise<Array<string>> | Promise used to return the list of URIs (starting with **dataability://**) that store the selected media assets.|
+| Promise<Array<string>> | Promise used to return the list of URIs (starting with **datashare://**) that store the selected media assets.|
**Example**
@@ -894,8 +891,6 @@ Obtains information about online peer devices. This API uses a promise to return
```js
async function example() {
- const context = getContext(this);
- var media = mediaLibrary.getMediaLibrary(context);
media.getActivePeers().then((devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
@@ -932,8 +927,6 @@ Obtains information about online peer devices. This API uses an asynchronous cal
```js
async function example() {
- const context = getContext(this);
- var media = mediaLibrary.getMediaLibrary(context);
media.getActivePeers((err, devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
@@ -969,8 +962,6 @@ Obtains information about all peer devices. This API uses a promise to return th
```js
async function example() {
- const context = getContext(this);
- var media = mediaLibrary.getMediaLibrary(context);
media.getAllPeers().then((devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
@@ -1007,8 +998,6 @@ Obtains information about online peer devices. This API uses an asynchronous cal
```js
async function example() {
- const context = getContext(this);
- var media = mediaLibrary.getMediaLibrary(context);
media.getAllPeers((err, devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
@@ -1032,7 +1021,7 @@ Provides APIs for encapsulating file asset attributes.
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. |
-| uri | string | Yes | No | File asset URI, for example, **dataability:///media/image/2**. |
+| uri | string | Yes | No | File asset URI, for example, **datashare:///media/image/2**. |
| mimeType | string | Yes | No | Extended file attributes. |
| mediaType8+ | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. |
@@ -2016,7 +2005,7 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ----------------------------------------- |
-| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the next file asset.|
+| callback| AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the next file asset.|
**Example**
@@ -2486,12 +2475,12 @@ Enumerates media types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
-| Name | Description|
-| ----- | ---- |
-| FILE | File.|
-| IMAGE | Image.|
-| VIDEO | Video.|
-| AUDIO | Audio.|
+| Name | Value| Description|
+| ----- | ---- | ---- |
+| FILE | 0 | File.|
+| IMAGE | 1 | Image.|
+| VIDEO | 2 | Video.|
+| AUDIO | 3 | Audio.|
## FileKey8+
@@ -2499,7 +2488,7 @@ Enumerates key file information.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
-| Name | Default Value | Description |
+| Name | Value | Description |
| ------------- | ------------------- | ---------------------------------------------------------- |
| ID | file_id | File ID. |
| RELATIVE_PATH | relative_path | Relative public directory of the file. |
@@ -2527,14 +2516,14 @@ Enumerates directory types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
-| Name | Description |
-| ------------- | ------------------ |
-| DIR_CAMERA | Directory of camera files.|
-| DIR_VIDEO | Directory of video files. |
-| DIR_IMAGE | Directory of image files. |
-| DIR_AUDIO | Directory of audio files. |
-| DIR_DOCUMENTS | Directory of documents. |
-| DIR_DOWNLOAD | Download directory. |
+| Name | Value| Description |
+| ------------- | --- | ------------------ |
+| DIR_CAMERA | 0 | Directory of camera files.|
+| DIR_VIDEO | 1 | Directory of video files. |
+| DIR_IMAGE | 2 | Directory of image files. |
+| DIR_AUDIO | 3 | Directory of audio files. |
+| DIR_DOCUMENTS | 4 | Directory of documents. |
+| DIR_DOWNLOAD | 5 | Download directory. |
## DeviceType8+
@@ -2544,15 +2533,15 @@ Enumerates device types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore
-| Name | Description |
-| ------------ | ---------- |
-| TYPE_UNKNOWN | Unknown.|
-| TYPE_LAPTOP | Laptop.|
-| TYPE_PHONE | Phone. |
-| TYPE_TABLET | Tablet. |
-| TYPE_WATCH | Smart watch. |
-| TYPE_CAR | Vehicle-mounted device. |
-| TYPE_TV | TV. |
+| Name | Value| Description |
+| ------------ | --- | ---------- |
+| TYPE_UNKNOWN | 0 | Unknown.|
+| TYPE_LAPTOP | 1 | Laptop.|
+| TYPE_PHONE | 2 | Phone. |
+| TYPE_TABLET | 3 | Tablet. |
+| TYPE_WATCH | 4 | Smart watch. |
+| TYPE_CAR | 5 | Vehicle-mounted device. |
+| TYPE_TV | 6 | TV. |
## MediaFetchOptions7+
@@ -2560,14 +2549,14 @@ Describes options for fetching media files.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
-| Name | Type | Readable| Writable| Mandatory| Description |
-| ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ |
-| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
-| selectionArgs | Array<string> | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.
Example:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
-| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " ASC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
-| uri8+ | string | Yes | Yes | No | File URI. |
-| networkId8+ | string | Yes | Yes | No | Network ID of the registered device. |
-| extendArgs8+ | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. |
+| Name | Type | Readable| Writable| Description |
+| ----------------------- | ------------------- | ---- | ---- | ------------------------------------------------------------ |
+| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
+| selectionArgs | Array<string> | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.
Example:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
+| order | string | Yes | Yes | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " ASC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
+| uri8+ | string | Yes | Yes | File URI. |
+| networkId8+ | string | Yes | Yes | Network ID of the registered device. |
+| extendArgs8+ | string | Yes | Yes | Extended parameters for fetching the files. Currently, no extended parameters are available. |
## Size8+
@@ -2591,11 +2580,11 @@ Implements the media asset option.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
-| Name | Type | Mandatory| Description |
-| ------------ | ------ | ---- | ------------------------------------------------------------ |
-| src | string | Yes | Application sandbox oath of the local file. |
-| mimeType | string | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.
The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
-| relativePath | string | No | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.
Default path of images: 'Pictures/'
Default path of videos: 'Videos/'
Default path of audios: 'Audios/'
Default path of files: 'Documents/'|
+| Name | Type | Readable| Writable| Description |
+| ------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
+| src | string | Yes | Yes | Application sandbox oath of the local file. |
+| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.
The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
+| relativePath | string | Yes | Yes | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.
Default path of images: 'Pictures/'
Default path of videos: 'Videos/'
Default path of audios: 'Audios/'
Default path of files: 'Documents/'|
## MediaSelectOption(deprecated)
@@ -2607,7 +2596,7 @@ Describes media selection option.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
-| Name | Type | Mandatory | Description |
-| ----- | ------ | ---- | -------------------- |
-| type | string | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
-| count | number | Yes | Number of media assets selected. The value starts from 1, which indicates that one media asset can be selected. |
+| Name | Type | Readable| Writable| Description |
+| ----- | ------ | ---- | ---- | -------------------- |
+| type | string | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
+| count | number | Yes | Yes | Number of media assets selected. The value starts from 1, which indicates that one media asset can be selected. |
diff --git a/en/application-dev/windowmanager/application-window-fa.md b/en/application-dev/windowmanager/application-window-fa.md
index 6914e775e568eb3615808fb185068ceaf7fac0b4..4fb66f780f7b0065acd9cbc0a9c491ce5a4c2bdf 100644
--- a/en/application-dev/windowmanager/application-window-fa.md
+++ b/en/application-dev/windowmanager/application-window-fa.md
@@ -31,7 +31,7 @@ The table below lists the common APIs used for application window development. F
| Window | setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void | Sets whether to enable the full-screen mode for this window.|
| Window | setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void | Sets whether to enable the full-screen mode for the window layout. |
| Window | setSystemBarEnable(names: Array<'status'\|'navigation'>): Promise<void> | Sets whether to display the status bar and navigation bar in this window.|
-| Window | setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void | Sets the properties of the status bar and navigation bar in this window.
`systemBarProperties`: properties of the status bar and navigation bar.|
+| Window | setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void | Sets the properties of the status bar and navigation bar in this window.
**systemBarProperties**: properties of the status bar and navigation bar.|
| Window | show(callback: AsyncCallback\): void | Shows this window.|
| Window | on(type: 'touchOutside', callback: Callback<void>): void | Enables listening for click events outside this window.|
| Window | destroy(callback: AsyncCallback<void>): void | Destroys this window.|
@@ -46,9 +46,9 @@ You can create a subwindow, such as a dialog box, and set its properties.
1. Create or obtain a subwindow.
- - Call `window.create` to create a subwindow.
- - Call `window.getTopWindow` to obtain the top window – subwindow.
- - Call `window.find` to find an available subwindow.
+ - Call **window.create** to create a subwindow.
+ - Call **window.getTopWindow** to obtain the top window – subwindow.
+ - Call **window.find** to find an available subwindow.
```js
import window from '@ohos.window';
@@ -89,61 +89,58 @@ You can create a subwindow, such as a dialog box, and set its properties.
```js
// Move the subwindow.
- windowClass.moveTo(300, 300, (err, data) => {
+ 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. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in moving the window.');
});
// Change the size of the subwindow.
- windowClass.resetSize(500, 1000, (err, data) => {
+ 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. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in changing the window size.');
});
```
3. Load content for the subwindow and show it.
- Call `loadContent` and `show` to load and display the content in the subwindow.
+ Call **loadContent** and **show** to load and display the content in the subwindow.
```js
// Load the page content to the subwindow.
- windowClass.loadContent("pages/page2", (err, data) => {
+ windowClass.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. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in loading the content.');
// Show the subwindow.
- windowClass.show((err, data) => {
+ 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. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in showing the window.');
});
});
```
4. Destroy the subwindow.
- When the subwindow is no longer needed, you can call `destroy` to destroy it.
+ When the subwindow is no longer needed, you can call **destroy()** to destroy it.
```js
- // Destroy the subwindow when a click event outside the window is detected.
- windowClass.on('touchOutside', () => {
- console.info('touch outside');
- windowClass.destroy((err, data) => {
- if (err.code) {
- console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in destroying the subwindow. Data: ' + JSON.stringify(data));
- });
+ // Call destroy() to destroy the subwindow when it is no longer needed.
+ windowClass.destroy((err) => {
+ if (err.code) {
+ console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in destroying the subwindow.');
});
```
@@ -161,7 +158,7 @@ To create a better video watching and gaming experience, you can use the immersi
>
> The immersive window feature can be implemented only after the main window is obtained.
>
- > Ensure that the top window of the application is the main window. You can use `window.getTopWindow` to obtain the main window.
+ > Ensure that the top window of the application is the main window. You can use **window.getTopWindow** to obtain the main window.
```js
import window from '@ohos.window';
@@ -180,76 +177,73 @@ To create a better video watching and gaming experience, you can use the immersi
2. Implement the immersive effect. You can use any of the following methods:
- - Method 1: Call `setFullScreen` to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
- - Method 2: Call `setSystemBarEnable` to hide the navigation bar and status bar.
- - Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
+ - Method 1: Call **setFullScreen** to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
+ - Method 2: Call **setSystemBarEnable** to hide the navigation bar and status bar.
+ - Method 3: Call **setLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setSystemProperties** to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
```js
// Use method 1 to implement the immersive effect.
let isFullScreen = true;
- mainWindowClass.setFullScreen(isFullScreen, (err, data) => {
+ mainWindowClass.setFullScreen(isFullScreen, (err) => {
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));
+ console.info('Succeeded in enabling the full-screen mode.');
});
// Use method 2 to implement the immersive effect.
let names = [];
- mainWindowClass.setSystemBarEnable(names, (err, data) => {
+ mainWindowClass.setSystemBarEnable(names, (err) => {
if (err.code) {
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
return;
}
- console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in setting the system bar to be visible.');
});
// Use method 3 to implement the immersive effect.
let isLayoutFullScreen = true;
- mainWindowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
+ mainWindowClass.setLayoutFullScreen(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. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in setting the window layout to full-screen mode.');
});
let sysBarProps = {
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
- // The following properties are supported since API version 7.
- isStatusBarLightIcon: false,
- isNavigationBarLightIcon: false,
// The following properties are supported since API version 8.
statusBarContentColor: '#ffffff',
navigationBarContentColor: '#ffffff'
};
- mainWindowClass.setSystemBarProperties(sysBarProps, (err, data) => {
+ mainWindowClass.setSystemBarProperties(sysBarProps, (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. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in setting the system bar properties.');
});
```
3. Load content for the immersive window and show it.
- Call `loadContent` and `show` to load and display the content in the immersive window.
+ Call **loadContent** and **show** to load and display the content in the immersive window.
```js
// Load the page content to the immersive window.
- mainWindowClass.loadContent("pages/page3", (err, data) => {
+ mainWindowClass.loadContent("pages/page3", (err) => {
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));
+ console.info('Succeeded in loading the content.');
// Show the immersive window.
- mainWindowClass.show((err, data) => {
+ mainWindowClass.show((err) => {
if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
return;
}
- console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
+ console.info('Succeeded in showing the window.');
});
});
```