提交 4978b75b 编写于 作者: E ester.zhou

Update docs (12508)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 ff0fb4a5
...@@ -9,7 +9,6 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 ...@@ -9,7 +9,6 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
- Method 2: Run the screenshot script. Connect to the development board to a computer running Windows. Create a text file on the computer, copy the following script content to the file, change the file name extension to **.bat** (the HDC environment variables must be configured in advance), and click **Run**. The screenshot is saved to the same directory as the **.bat** script file. - Method 2: Run the screenshot script. Connect to the development board to a computer running Windows. Create a text file on the computer, copy the following script content to the file, change the file name extension to **.bat** (the HDC environment variables must be configured in advance), and click **Run**. The screenshot is saved to the same directory as the **.bat** script file.
Example: Example:
``` ```
set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png
echo %filepath% echo %filepath%
...@@ -29,10 +28,11 @@ Applicable to: DevEco Studio 3.0.0.991 ...@@ -29,10 +28,11 @@ Applicable to: DevEco Studio 3.0.0.991
![en-us_image_0000001361254285](figures/en-us_image_0000001361254285.png) ![en-us_image_0000001361254285](figures/en-us_image_0000001361254285.png)
2. Set the profile parameters as follows: 2. Set the profile parameters as follows:
Device type : default Device type : default
Resolution: 720\*1280 Resolution: 720\*1280
DPI: 240 DPI: 240
## What should I do if Device Manager incorrectly identifies a development board as FT232R USB UART even when the development board already has a driver installed? ## What should I do if Device Manager incorrectly identifies a development board as FT232R USB UART even when the development board already has a driver installed?
......
# @ohos.accessibility.GesturePath # @ohos.accessibility.GesturePath (Gesture Path)
The **GesturePath** module provides APIs for creating gesture path information required for an accessibility application to inject gestures. The **GesturePath** module provides APIs for creating gesture path information required for an accessibility application to inject gestures.
......
# @ohos.accessibility.GesturePoint # @ohos.accessibility.GesturePoint (Gesture Point)
The **GesturePoint** module provides APIs for creating gesture touch point information required for an accessibility application to inject gestures. The **GesturePoint** module provides APIs for creating gesture touch point information required for an accessibility application to inject gestures.
> **NOTE** > **NOTE**
> >
......
# @ohos.accessibility.config # @ohos.accessibility.config (System Accessibility Configuration)
The System Accessibility Configuration module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions. The System Accessibility Configuration module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
......
# @ohos.accessibility # @ohos.accessibility (Accessibility)
The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration. The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration.
......
# @ohos.animator # @ohos.animator (Animator)
The **animator** module provides APIs for applying animation effects, including defining animations, starting animations, and playing animations in reverse order. The **Animator** module provides APIs for applying animation effects, including defining animations, starting animations, and playing animations in reverse order.
> **NOTE** > **NOTE**
> >
......
# @ohos.curves # @ohos.curves (Interpolation Calculation)
The **Curves** module provides APIs for interpolation calculation to create step, cubic Bezier, and spring curves. The **Curves** module provides APIs for interpolation calculation to create step, cubic Bezier, and spring curves.
......
# @ohos.deviceInfo # @ohos.deviceInfo (Device Information)
The **deviceInfo** module provides product information. The **deviceInfo** module provides product information.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
......
# @ohos.enterprise.dateTimeManager # @ohos.enterprise.dateTimeManager (System Time Management)
The **dateTimeManager** module provides APIs for system time management, which can only be called by device administrator applications. The **dateTimeManager** module provides APIs for system time management, which can only be called by device administrator applications.
......
# Environment # @ohos.environment (Directory Environment Capability)
The **Environment** module provides APIs for obtaining the root directories of the storage and public files. The **Environment** module provides APIs for obtaining the root directories of the storage and public files.
......
# InputMethodExtensionAbility # @ohos.inputmethodextensionability (InputMethodExtensionAbility)
The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles. The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles.
......
# @ohos.inputmethodsubtype # @ohos.inputmethodsubtype (Input Method Subtype)
The **inputMethodSubtype** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes. The **inputMethodSubtype** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes.
......
# @ohos.inputmethod # @ohos.inputmethod (Input Method Framework)
The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more. The **inputMethod** module provides an input method framework, which can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more.
......
# @ohos.inputmethodengine # @ohos.inputmethodengine (Input Method Service)
The **inputMethodEngine** module streamlines the interaction between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input through the input methods, request the keyboard to display or hide, listen for the input method status, and much more. The **inputMethodEngine** module streamlines the interaction between input methods and applications. By calling APIs of this module, applications can be bound to input method services to accept text input through the input methods, request the keyboard to display or hide, listen for the input method status, and much more.
......
# @ohos.matrix4 # @ohos.matrix4 (Matrix Transformation)
The **matrix4** module provides APIs for matrix transformation. You can use these APIs to translate, rotate, and scale images. The **matrix4** module provides APIs for matrix transformation. You can use these APIs to translate, rotate, and scale images.
......
# @ohos.mediaquery # @ohos.mediaquery (Media Query)
The **mediaquery** module provides different styles for different media types. The **mediaquery** module provides different styles for different media types.
......
# Pasteboard # @ohos.pasteboard (Pasteboard)
The **pasteboard** module provides the copy and paste support for the system pasteboard. You can use the APIs of this module to operate pasteboard content of the plain text, HTML, URI, Want, pixel map, and other types. The **pasteboard** module provides the copy and paste support for the system pasteboard. You can use the APIs of this module to operate pasteboard content of the plain text, HTML, URI, Want, pixel map, and other types.
...@@ -120,11 +120,11 @@ Enumerates the paste options of data. ...@@ -120,11 +120,11 @@ Enumerates the paste options of data.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
| Name | Description | | Name| Value| Description |
| ----- | ----------------------- | | ---- |---|-------------------|
| InApp |Only intra-application pasting is allowed.| | InApp | 0 | Only intra-application pasting is allowed. |
| LocalDevice |Paste is allowed in any application on the local device.| | LocalDevice | 1 | Paste is allowed in any application on the local device.|
| CrossDevice |Paste is allowed in any application across devices.| | CrossDevice | 2 | Paste is allowed in any application across devices. |
## pasteboard.createHtmlData<sup>(deprecated)</sup> ## pasteboard.createHtmlData<sup>(deprecated)</sup>
...@@ -418,7 +418,7 @@ Forcibly converts the content in a **PasteData** object to text. This API uses a ...@@ -418,7 +418,7 @@ Forcibly converts the content in a **PasteData** object to text. This API uses a
**Example** **Example**
```js ```js
let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt'); let record = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt');
record.convertToTextV9((err, data) => { record.convertToTextV9((err, data) => {
if (err) { if (err) {
console.error(`Failed to convert to text. Cause: ${err.message}`); console.error(`Failed to convert to text. Cause: ${err.message}`);
...@@ -445,7 +445,7 @@ Forcibly converts the content in a **PasteData** object to text. This API uses a ...@@ -445,7 +445,7 @@ Forcibly converts the content in a **PasteData** object to text. This API uses a
**Example** **Example**
```js ```js
let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt'); let record = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt');
record.convertToTextV9().then((data) => { record.convertToTextV9().then((data) => {
console.info(`Succeeded in converting to text. Data: ${data}`); console.info(`Succeeded in converting to text. Data: ${data}`);
}).catch((err) => { }).catch((err) => {
...@@ -536,7 +536,7 @@ Obtains the plain text of the primary record. ...@@ -536,7 +536,7 @@ Obtains the plain text of the primary record.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let plainText = pasteData.getPrimaryText(); let plainText = pasteData.getPrimaryText();
``` ```
...@@ -558,7 +558,7 @@ Obtains the HTML content of the primary record. ...@@ -558,7 +558,7 @@ Obtains the HTML content of the primary record.
```js ```js
let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
let pasteData = pasteboard.createHtmlData(html); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, html);
let htmlText = pasteData.getPrimaryHtml(); let htmlText = pasteData.getPrimaryHtml();
``` ```
...@@ -583,7 +583,7 @@ let object = { ...@@ -583,7 +583,7 @@ let object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
let pasteData = pasteboard.createWantData(object); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_WANT, object);
let want = pasteData.getPrimaryWant(); let want = pasteData.getPrimaryWant();
``` ```
...@@ -604,7 +604,7 @@ Obtains the URI of the primary record. ...@@ -604,7 +604,7 @@ Obtains the URI of the primary record.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt');
let uri = pasteData.getPrimaryUri(); let uri = pasteData.getPrimaryUri();
``` ```
...@@ -636,7 +636,7 @@ let opt = { ...@@ -636,7 +636,7 @@ let opt = {
scaleMode: 1 scaleMode: 1
}; };
image.createPixelMap(buffer, opt).then((pixelMap) => { image.createPixelMap(buffer, opt).then((pixelMap) => {
let pasteData = pasteboard.createData('app/xml',pixelMap); let pasteData = pasteboard.createData(MIMETYPE_PIXELMAP, pixelMap);
let PixelMap = pasteData.getPrimaryPixelMap(); let PixelMap = pasteData.getPrimaryPixelMap();
}); });
``` ```
...@@ -660,10 +660,10 @@ The pasteboard supports a maximum number of 512 data records. ...@@ -660,10 +660,10 @@ The pasteboard supports a maximum number of 512 data records.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt');
let textRecord = pasteboard.createPlainTextRecord('hello'); let textRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
let htmlRecord = pasteboard.createHtmlTextRecord(html); let htmlRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_HTML, html);
pasteData.addRecord(textRecord); pasteData.addRecord(textRecord);
pasteData.addRecord(htmlRecord); pasteData.addRecord(htmlRecord);
``` ```
...@@ -695,7 +695,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ...@@ -695,7 +695,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example** **Example**
```js ```js
let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt');
let dataXml = new ArrayBuffer(256); let dataXml = new ArrayBuffer(256);
pasteData.addRecord('app/xml', dataXml); pasteData.addRecord('app/xml', dataXml);
``` ```
...@@ -717,7 +717,7 @@ Obtains a list of **mimeTypes** objects in [PasteDataProperty](#pastedatapropert ...@@ -717,7 +717,7 @@ Obtains a list of **mimeTypes** objects in [PasteDataProperty](#pastedatapropert
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let types = pasteData.getMimeTypes(); let types = pasteData.getMimeTypes();
``` ```
...@@ -738,7 +738,7 @@ Obtains the data type of the primary record in this pasteboard. ...@@ -738,7 +738,7 @@ Obtains the data type of the primary record in this pasteboard.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let type = pasteData.getPrimaryMimeType(); let type = pasteData.getPrimaryMimeType();
``` ```
...@@ -759,7 +759,7 @@ Obtains the property of the pasteboard data. ...@@ -759,7 +759,7 @@ Obtains the property of the pasteboard data.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let property = pasteData.getProperty(); let property = pasteData.getProperty();
``` ```
...@@ -780,7 +780,7 @@ Sets the property (attributes) for the pasteboard data. Currently, only the **sh ...@@ -780,7 +780,7 @@ Sets the property (attributes) for the pasteboard data. Currently, only the **sh
**Example** **Example**
```js ```js
let pasteData = pasteboard.createHtmlData('application/xml'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, 'application/xml');
let prop = pasteData.getProperty(); let prop = pasteData.getProperty();
prop.shareOption = pasteboard.ShareOption.InApp; prop.shareOption = pasteboard.ShareOption.InApp;
pasteData.setProperty(prop); pasteData.setProperty(prop);
...@@ -817,7 +817,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ...@@ -817,7 +817,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let record = pasteData.getRecord(0); let record = pasteData.getRecord(0);
``` ```
...@@ -838,7 +838,7 @@ Obtains the number of records in the pasteboard. ...@@ -838,7 +838,7 @@ Obtains the number of records in the pasteboard.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let count = pasteData.getRecordCount(); let count = pasteData.getRecordCount();
``` ```
...@@ -859,7 +859,7 @@ Obtains the custom tag from the pasteboard. If no custom tag is set, null is ret ...@@ -859,7 +859,7 @@ Obtains the custom tag from the pasteboard. If no custom tag is set, null is ret
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let tag = pasteData.getTag(); let tag = pasteData.getTag();
``` ```
...@@ -886,7 +886,7 @@ Checks whether the pasteboard contains data of the specified type. ...@@ -886,7 +886,7 @@ Checks whether the pasteboard contains data of the specified type.
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN); let hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
...@@ -915,7 +915,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ...@@ -915,7 +915,7 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
pasteData.removeRecord(0); pasteData.removeRecord(0);
``` ```
...@@ -945,8 +945,8 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ...@@ -945,8 +945,8 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er
**Example** **Example**
```js ```js
let pasteData = pasteboard.createPlainTextData('hello'); let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, 'hello');
let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt'); let record = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt');
pasteData.replaceRecord(0, record); pasteData.replaceRecord(0, record);
``` ```
### addHtmlRecord<sup>(deprecated)</sup> ### addHtmlRecord<sup>(deprecated)</sup>
......
# @ohos.prompt # @ohos.prompt (Prompt)
The **Prompt** module provides APIs for creating and showing toasts, dialog boxes, and action menus. The **Prompt** module provides APIs for creating and showing toasts, dialog boxes, and action menus.
......
# @ohos.promptAction # @ohos.promptAction (Prompt)
The **PromptAction** module provides APIs for creating and showing toasts, dialog boxes, and action menus. The **PromptAction** module provides APIs for creating and showing toasts, dialog boxes, and action menus.
......
# @ohos.router # @ohos.router (Page Routing)
The **Router** module provides APIs to access pages through URLs. You can use the APIs to navigate to a specified page in an application, replace the current page with another one in an application, and return to the previous page or a specified page. The **Router** module provides APIs to access pages through URLs. You can use the APIs to navigate to a specified page in an application, replace the current page with another one in an application, and return to the previous page or a specified page.
......
# @ohos.settings # @ohos.settings (Data Item Settings)
The **settings** module provides APIs for setting data items. The **settings** module provides APIs for setting data items.
......
# @ohos.systemDateTime # @ohos.systemDateTime (System Time and Time Zone)
The **systemDateTime** module provides system time and time zone features. You can use the APIs of this module to set and obtain the system time and time zone. The **systemDateTime** module provides system time and time zone features. You can use the APIs of this module to set and obtain the system time and time zone.
...@@ -35,15 +35,15 @@ Sets the system time. This API uses an asynchronous callback to return the resul ...@@ -35,15 +35,15 @@ Sets the system time. This API uses an asynchronous callback to return the resul
// Set the system time to 2021-01-20 02:36:25. // Set the system time to 2021-01-20 02:36:25.
let time = 1611081385000; let time = 1611081385000;
try { try {
systemDateTime.setTime(time, (error) => { systemDateTime.setTime(time, (error) => {
if (error) { if (error) {
console.info(`Failed to set time. message:${error.message}, code:${error.code}`); console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in setting time`); console.info(`Succeeded in setting time`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to set time. message:${e.message}, code:${e.code}`); console.info(`Failed to set time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -75,13 +75,13 @@ Sets the system time. This API uses a promise to return the result. ...@@ -75,13 +75,13 @@ Sets the system time. This API uses a promise to return the result.
// Set the system time to 2021-01-20 02:36:25. // Set the system time to 2021-01-20 02:36:25.
let time = 1611081385000; let time = 1611081385000;
try { try {
systemDateTime.setTime(time).then(() => { systemDateTime.setTime(time).then(() => {
console.info(`Succeeded in setting time.`); console.info(`Succeeded in setting time.`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to set time. message:${error.message}, code:${error.code}`); console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to set time. message:${e.message}, code:${e.code}`); console.info(`Failed to set time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -104,15 +104,15 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal ...@@ -104,15 +104,15 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
```js ```js
try { try {
systemDateTime.getCurrentTime(true, (error, time) => { systemDateTime.getCurrentTime(true, (error, time) => {
if (error) { if (error) {
console.info(`Failed to get currentTime. message:${error.message}, code:${error.code}`); console.info(`Failed to get currentTime. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting currentTime : ${time}`); console.info(`Succeeded in getting currentTime : ${time}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get currentTime. message:${e.message}, code:${e.code}`); console.info(`Failed to get currentTime. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -134,15 +134,15 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal ...@@ -134,15 +134,15 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
```js ```js
try { try {
systemDateTime.getCurrentTime((error, time) => { systemDateTime.getCurrentTime((error, time) => {
if (error) { if (error) {
console.info(`Failed to get currentTime. message:${error.message}, code:${error.code}`); console.info(`Failed to get currentTime. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting currentTime : ${time}`); console.info(`Succeeded in getting currentTime : ${time}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get currentTime. message:${e.message}, code:${e.code}`); console.info(`Failed to get currentTime. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -170,13 +170,13 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return ...@@ -170,13 +170,13 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return
```js ```js
try { try {
systemDateTime.getCurrentTime().then((time) => { systemDateTime.getCurrentTime().then((time) => {
console.info(`Succeeded in getting currentTime : ${time}`); console.info(`Succeeded in getting currentTime : ${time}`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to get currentTime. message:${error.message}, code:${error.code}`); console.info(`Failed to get currentTime. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get currentTime. message:${e.message}, code:${e.code}`); console.info(`Failed to get currentTime. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -199,15 +199,15 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th ...@@ -199,15 +199,15 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th
```js ```js
try { try {
systemDateTime.getRealActiveTime(true, (error, time) => { systemDateTime.getRealActiveTime(true, (error, time) => {
if (error) { if (error) {
console.info(`Failed to get real active time. message:${error.message}, code:${error.code}`); console.info(`Failed to get real active time. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting real active time : ${time}`); console.info(`Succeeded in getting real active time : ${time}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get real active time. message:${e.message}, code:${e.code}`); console.info(`Failed to get real active time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -229,15 +229,15 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th ...@@ -229,15 +229,15 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th
```js ```js
try { try {
systemDateTime.getRealActiveTime((error, time) => { systemDateTime.getRealActiveTime((error, time) => {
if (error) { if (error) {
console.info(`Failed to get real active time. message:${error.message}, code:${error.code}`); console.info(`Failed to get real active time. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting real active time : ${time}`); console.info(`Succeeded in getting real active time : ${time}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get real active time. message:${e.message}, code:${e.code}`); console.info(`Failed to get real active time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -265,13 +265,13 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th ...@@ -265,13 +265,13 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th
```js ```js
try { try {
systemDateTime.getRealActiveTime().then((time) => { systemDateTime.getRealActiveTime().then((time) => {
console.info(`Succeeded in getting real active time : ${time}`); console.info(`Succeeded in getting real active time : ${time}`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to get real active time. message:${error.message}, code:${error.code}`); console.info(`Failed to get real active time. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get real active time. message:${e.message}, code:${e.code}`); console.info(`Failed to get real active time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -294,15 +294,15 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th ...@@ -294,15 +294,15 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th
```js ```js
try { try {
systemDateTime.getRealTime(true, (error, time) => { systemDateTime.getRealTime(true, (error, time) => {
if (error) { if (error) {
console.info(`Failed to get real time. message:${error.message}, code:${error.code}`); console.info(`Failed to get real time. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting real time : ${time}`); console.info(`Succeeded in getting real time : ${time}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get real time. message:${e.message}, code:${e.code}`); console.info(`Failed to get real time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -324,15 +324,15 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th ...@@ -324,15 +324,15 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th
```js ```js
try { try {
systemDateTime.getRealTime((error, time) => { systemDateTime.getRealTime((error, time) => {
if (error) { if (error) {
console.info(`Failed to get real time. message:${error.message}, code:${error.code}`); console.info(`Failed to get real time. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting real time : ${time}`); console.info(`Succeeded in getting real time : ${time}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get real time. message:${e.message}, code:${e.code}`); console.info(`Failed to get real time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -360,13 +360,13 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th ...@@ -360,13 +360,13 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th
```js ```js
try { try {
systemDateTime.getRealTime().then((time) => { systemDateTime.getRealTime().then((time) => {
console.info(`Succeeded in getting real time : ${time}`); console.info(`Succeeded in getting real time : ${time}`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to get real time. message:${error.message}, code:${error.code}`); console.info(`Failed to get real time. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get real time. message:${e.message}, code:${e.code}`); console.info(`Failed to get real time. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -392,15 +392,15 @@ Sets the system date. This API uses an asynchronous callback to return the resul ...@@ -392,15 +392,15 @@ Sets the system date. This API uses an asynchronous callback to return the resul
```js ```js
let date = new Date(); let date = new Date();
try { try {
systemDateTime.setDate(date, (error) => { systemDateTime.setDate(date, (error) => {
if (error) { if (error) {
console.info(`Failed to set date. message:${error.message}, code:${error.code}`); console.info(`Failed to set date. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in setting date.`); console.info(`Succeeded in setting date.`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to set date. message:${e.message}, code:${e.code}`); console.info(`Failed to set date. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -431,13 +431,13 @@ Sets the system date. This API uses a promise to return the result. ...@@ -431,13 +431,13 @@ Sets the system date. This API uses a promise to return the result.
```js ```js
let date = new Date(); let date = new Date();
try { try {
systemDateTime.setDate(date).then(() => { systemDateTime.setDate(date).then(() => {
console.info(`Succeeded in setting date.`); console.info(`Succeeded in setting date.`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to set date. message:${error.message}, code:${error.code}`); console.info(`Failed to set date. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to set date. message:${e.message}, code:${e.code}`); console.info(`Failed to set date. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -459,15 +459,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur ...@@ -459,15 +459,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur
```js ```js
try { try {
systemDateTime.getDate((error, date) => { systemDateTime.getDate((error, date) => {
if (error) { if (error) {
console.info(`Failed to get date. message:${error.message}, code:${error.code}`); console.info(`Failed to get date. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in getting date : ${date}`);; console.info(`Succeeded in getting date : ${date}`);;
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get date. message:${e.message}, code:${e.code}`); console.info(`Failed to get date. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -489,13 +489,13 @@ Obtains the current system date. This API uses a promise to return the result. ...@@ -489,13 +489,13 @@ Obtains the current system date. This API uses a promise to return the result.
```js ```js
try { try {
systemDateTime.getDate().then((date) => { systemDateTime.getDate().then((date) => {
console.info(`Succeeded in getting date : ${date}`); console.info(`Succeeded in getting date : ${date}`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to get date. message:${error.message}, code:${error.code}`); console.info(`Failed to get date. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get date. message:${e.message}, code:${e.code}`); console.info(`Failed to get date. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -520,15 +520,15 @@ Sets the system time zone. This API uses an asynchronous callback to return the ...@@ -520,15 +520,15 @@ Sets the system time zone. This API uses an asynchronous callback to return the
```js ```js
try { try {
systemDateTime.setTimezone('Asia/Shanghai', (error) => { systemDateTime.setTimezone('Asia/Shanghai', (error) => {
if (error) { if (error) {
console.info(`Failed to set timezone. message:${error.message}, code:${error.code}`); console.info(`Failed to set timezone. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in setting timezone.`); console.info(`Succeeded in setting timezone.`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to set timezone. message:${e.message}, code:${e.code}`); console.info(`Failed to set timezone. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -558,13 +558,13 @@ Sets the system time zone. This API uses a promise to return the result. ...@@ -558,13 +558,13 @@ Sets the system time zone. This API uses a promise to return the result.
```js ```js
try { try {
systemDateTime.setTimezone('Asia/Shanghai').then(() => { systemDateTime.setTimezone('Asia/Shanghai').then(() => {
console.info(`Succeeded in setting timezone.`); console.info(`Succeeded in setting timezone.`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to set timezone. message:${error.message}, code:${error.code}`); console.info(`Failed to set timezone. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to set timezone. message:${e.message}, code:${e.code}`); console.info(`Failed to set timezone. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -586,15 +586,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t ...@@ -586,15 +586,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t
```js ```js
try { try {
systemDateTime.getTimezone((error, data) => { systemDateTime.getTimezone((error, data) => {
if (error) { if (error) {
console.info(`Failed to get timezone. message:${error.message}, code:${error.code}`); console.info(`Failed to get timezone. message: ${error.message}, code: ${error.code}`);
return; return;
} }
console.info(`Succeeded in get timezone : ${data}`);; console.info(`Succeeded in get timezone : ${data}`);;
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get timezone. message:${e.message}, code:${e.code}`); console.info(`Failed to get timezone. message: ${e.message}, code: ${e.code}`);
} }
``` ```
...@@ -616,13 +616,13 @@ Obtains the system time zone. This API uses a promise to return the result. ...@@ -616,13 +616,13 @@ Obtains the system time zone. This API uses a promise to return the result.
```js ```js
try { try {
systemDateTime.getTimezone().then((data) => { systemDateTime.getTimezone().then((data) => {
console.info(`Succeeded in getting timezone: ${data}`); console.info(`Succeeded in getting timezone: ${data}`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to get timezone. message:${error.message}, code:${error.code}`); console.info(`Failed to get timezone. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to get timezone. message:${e.message}, code:${e.code}`); console.info(`Failed to get timezone. message: ${e.message}, code: ${e.code}`);
} }
``` ```
......
# @system.device # @system.device (Device Information)
The **device** module provides APIs for checking information about the current device. The **device** module provides APIs for checking information about the current device.
......
# Media Query # @system.mediaquery (Media Query)
The **mediaquery** module provides different styles for different media types. The **mediaquery** module provides different styles for different media types.
...@@ -12,7 +12,7 @@ The **mediaquery** module provides different styles for different media types. ...@@ -12,7 +12,7 @@ The **mediaquery** module provides different styles for different media types.
## Modules to Import ## Modules to Import
``` ```ts
import mediaquery from '@system.mediaquery'; import mediaquery from '@system.mediaquery';
``` ```
...@@ -39,8 +39,8 @@ Creates a **MediaQueryList** object based on the query condition. ...@@ -39,8 +39,8 @@ Creates a **MediaQueryList** object based on the query condition.
**Example** **Example**
``` ```ts
var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); let mMediaQueryList = mediaquery.matchMedia('(max-width: 466)');
``` ```
## MediaQueryEvent ## MediaQueryEvent
...@@ -97,7 +97,7 @@ Adds a listener for this **MediaQueryList** object. The listener must be added b ...@@ -97,7 +97,7 @@ Adds a listener for this **MediaQueryList** object. The listener must be added b
**Example** **Example**
``` ```ts
function maxWidthMatch(e){ function maxWidthMatch(e){
if(e.matches){ if(e.matches){
// do something // do something
...@@ -123,7 +123,7 @@ Removes the listener for this **MediaQueryList** object. ...@@ -123,7 +123,7 @@ Removes the listener for this **MediaQueryList** object.
**Example** **Example**
``` ```ts
function maxWidthMatch(e){ function maxWidthMatch(e){
if(e.matches){ if(e.matches){
// do something // do something
......
# @ohos.systemParameter # @ohos.systemParameter (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters. The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see For details about the system parameter design principles and definitions, see
......
# SystemParameter # SystemParameter (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters. The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see For details about the system parameter design principles and definitions, see
......
# Prompt # @system.prompt (Prompt)
The **PromptAction** module provides APIs for creating and showing toasts, dialog boxes, and action menus.
> **NOTE** > **NOTE**
> >
......
# @system.router # @system.router (Page Routing)
The **Router** module provides APIs to access pages through URIs. The **Router** module provides APIs to access pages through URIs.
......
# @ohos.systemTimer # @ohos.systemTimer (System Timer)
The **systemTimer** module provides system timer features. You can use the APIs of this module to implement the alarm clock and other timer services. The **systemTimer** module provides system timer features. You can use the APIs of this module to implement the alarm clock and other timer services.
...@@ -63,23 +63,23 @@ Creates a timer. This API uses an asynchronous callback to return the result. ...@@ -63,23 +63,23 @@ Creates a timer. This API uses an asynchronous callback to return the result.
```js ```js
export default { export default {
systemTimer () { systemTimer () {
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false repeat: false
}; };
try { try {
systemTimer.createTimer(options, (error) => { systemTimer.createTimer(options, (error, timerId) => {
if (error) { if (error) {
console.info(`Failed to create timer. message:${error.message}, code:${error.code}`); console.info(`Failed to create timer. message: ${error.message}, code: ${error.code}`);
return; return;
}
console.info(`Succeeded in creating timer.`);
});
} catch(e) {
console.info(`Failed to create timer. message:${e.message}, code:${e.code}`);
} }
console.info(`Succeeded in creating timer. timerId: ${timerId}`);
});
} catch(e) {
console.info(`Failed to create timer. message: ${e.message}, code: ${e.code}`);
} }
}
} }
``` ```
...@@ -109,21 +109,21 @@ Creates a timer. This API uses a promise to return the result. ...@@ -109,21 +109,21 @@ Creates a timer. This API uses a promise to return the result.
```js ```js
export default { export default {
systemTimer () { systemTimer () {
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
}; };
try { try {
systemTimer.createTimer(options).then(() => { systemTimer.createTimer(options).then((timerId) => {
console.info(`Succeeded in creating timer.`); console.info(`Succeeded in creating timer. timerId: ${timerId}`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to create timer. message:${error.message}, code:${error.code}`); console.info(`Failed to create timer. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to create timer. message:${e.message}, code:${e.code}`); console.info(`Failed to create timer. message: ${e.message}, code: ${e.code}`);
}
} }
}
} }
``` ```
...@@ -149,26 +149,26 @@ Starts a timer. This API uses an asynchronous callback to return the result. ...@@ -149,26 +149,26 @@ Starts a timer. This API uses an asynchronous callback to return the result.
```js ```js
export default { export default {
async systemTimer () { async systemTimer () {
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
}
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
try {
systemTimer.startTimer(timerId, triggerTime, (error) => {
if (error) {
console.info(`Failed to start timer. message: ${error.message}, code: ${error.code}`);
return;
} }
let timerId = await systemTimer.createTimer(options) console.info(`Succeeded in starting timer.`);
let triggerTime = new Date().getTime() });
triggerTime += 3000 } catch(e) {
try { console.info(`Failed to start timer. message: ${e.message}, code: ${e.code}`);
systemTimer.startTimer(timerId, triggerTime, (error) => {
if (error) {
console.info(`Failed to start timer. message:${error.message}, code:${error.code}`);
return;
}
console.info(`Succeeded in starting timer.`);
});
} catch(e) {
console.info(`Failed to start timer. message:${e.message}, code:${e.code}`);
}
} }
}
} }
``` ```
...@@ -199,24 +199,24 @@ Starts a timer. This API uses a promise to return the result. ...@@ -199,24 +199,24 @@ Starts a timer. This API uses a promise to return the result.
```js ```js
export default { export default {
async systemTimer (){ async systemTimer (){
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
}
let timerId = await systemTimer.createTimer(options)
let triggerTime = new Date().getTime()
triggerTime += 3000
try {
systemTimer.startTimer(timerId, triggerTime).then(() => {
console.info(`Succeeded in starting timer.`);
}).catch((error) => {
console.info(`Failed to start timer. message:${error.message}, code:${error.code}`);
});
} catch(e) {
console.info(`Failed to start timer. message:${e.message}, code:${e.code}`);
}
} }
let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime();
triggerTime += 3000;
try {
systemTimer.startTimer(timerId, triggerTime).then(() => {
console.info(`Succeeded in starting timer.`);
}).catch((error) => {
console.info(`Failed to start timer. message: ${error.message}, code: ${error.code}`);
});
} catch(e) {
console.info(`Failed to start timer. message: ${e.message}, code: ${e.code}`);
}
}
} }
``` ```
...@@ -241,27 +241,27 @@ Stops a timer. This API uses an asynchronous callback to return the result. ...@@ -241,27 +241,27 @@ Stops a timer. This API uses an asynchronous callback to return the result.
```js ```js
export default { export default {
async systemTimer () { async systemTimer () {
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
} }
let timerId = await systemTimer.createTimer(options) let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime() let triggerTime = new Date().getTime();
triggerTime += 3000 triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime) systemTimer.startTimer(timerId, triggerTime);
try { try {
systemTimer.stopTimer(timerId, (error) => { systemTimer.stopTimer(timerId, (error) => {
if (error) { if (error) {
console.info(`Failed to stop timer. message:${error.message}, code:${error.code}`); console.info(`Failed to stop timer. message: ${error.message}, code: ${error.code}`);
return; return;
}
console.info(`Succeeded in stopping timer.`);
});
} catch(e) {
console.info(`Failed to stop timer. message:${e.message}, code:${e.code}`);
} }
} console.info(`Succeeded in stopping timer.`);
});
} catch(e) {
console.info(`Failed to stop timer. message: ${e.message}, code: ${e.code}`);
}
}
} }
``` ```
...@@ -291,25 +291,25 @@ Stops a timer. This API uses a promise to return the result. ...@@ -291,25 +291,25 @@ Stops a timer. This API uses a promise to return the result.
```js ```js
export default { export default {
async systemTimer (){ async systemTimer (){
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
} }
let timerId = await systemTimer.createTimer(options) let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime() let triggerTime = new Date().getTime();
triggerTime += 3000 triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime) systemTimer.startTimer(timerId, triggerTime);
try { try {
systemTimer.stopTimer(timerId).then(() => { systemTimer.stopTimer(timerId).then(() => {
console.info(`Succeeded in stopping timer.`); console.info(`Succeeded in stopping timer.`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to stop timer. message:${error.message}, code:${error.code}`); console.info(`Failed to stop timer. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to stop timer. message:${e.message}, code:${e.code}`); console.info(`Failed to stop timer. message: ${e.message}, code: ${e.code}`);
}
} }
}
} }
``` ```
...@@ -334,28 +334,28 @@ Destroys a timer. This API uses an asynchronous callback to return the result. ...@@ -334,28 +334,28 @@ Destroys a timer. This API uses an asynchronous callback to return the result.
```js ```js
export default { export default {
async systemTimer () { async systemTimer () {
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
} }
let timerId = await systemTimer.createTimer(options) let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime() let triggerTime = new Date().getTime();
triggerTime += 3000 triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime) systemTimer.startTimer(timerId, triggerTime);
systemTimer.stopTimer(timerId) systemTimer.stopTimer(timerId);
try { try {
systemTimer.destroyTimer(timerId, (error) => { systemTimer.destroyTimer(timerId, (error) => {
if (error) { if (error) {
console.info(`Failed to destroy timer. message:${error.message}, code:${error.code}`); console.info(`Failed to destroy timer. message: ${error.message}, code: ${error.code}`);
return; return;
}
console.info(`Succeeded in destroying timer.`);
});
} catch(e) {
console.info(`Failed to destroying timer. message:${e.message}, code:${e.code}`);
} }
console.info(`Succeeded in destroying timer.`);
});
} catch(e) {
console.info(`Failed to destroying timer. message: ${e.message}, code: ${e.code}`);
} }
}
} }
``` ```
...@@ -385,25 +385,25 @@ Destroys a timer. This API uses a promise to return the result. ...@@ -385,25 +385,25 @@ Destroys a timer. This API uses a promise to return the result.
```js ```js
export default { export default {
async systemTimer (){ async systemTimer (){
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat:false repeat:false
} }
let timerId = await systemTimer.createTimer(options) let timerId = await systemTimer.createTimer(options);
let triggerTime = new Date().getTime() let triggerTime = new Date().getTime();
triggerTime += 3000 triggerTime += 3000;
systemTimer.startTimer(timerId, triggerTime) systemTimer.startTimer(timerId, triggerTime);
systemTimer.stopTimer(timerId) systemTimer.stopTimer(timerId);
try { try {
systemTimer.destroyTimer(timerId).then(() => { systemTimer.destroyTimer(timerId).then(() => {
console.info(`Succeeded in destroying timer.`); console.info(`Succeeded in destroying timer.`);
}).catch((error) => { }).catch((error) => {
console.info(`Failed to destroy timer. message:${error.message}, code:${error.code}`); console.info(`Failed to destroy timer. message: ${error.message}, code: ${error.code}`);
}); });
} catch(e) { } catch(e) {
console.info(`Failed to destroying timer. message:${e.message}, code:${e.code}`); console.info(`Failed to destroying timer. message: ${e.message}, code: ${e.code}`);
}
} }
}
} }
``` ```
# @ohos.uitest # @ohos.uitest (UiTest)
The **UiTest** module provides APIs that you can use to simulate UI actions during testing, such as clicks, double-clicks, long-clicks, and swipes. The **UiTest** module provides APIs that you can use to simulate UI actions during testing, such as clicks, double-clicks, long-clicks, and swipes.
......
# @ohos.wallpaper # @ohos.wallpaper (Wallpaper)
The **wallpaper** module is a system service module in OpenHarmony that provides the wallpaper management service. You can use the APIs of this module to show, set, and switch between wallpapers. The **wallpaper** module is a system service module in OpenHarmony that provides the wallpaper management service. You can use the APIs of this module to show, set, and switch between wallpapers.
......
# @ohos.web.webview (Webview)
# @ohos.web.webview
The **Webview** module provides APIs for web control. The **Webview** module provides APIs for web control.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册