未验证 提交 ac475512 编写于 作者: O openharmony_ci 提交者: Gitee

!5592 翻译完成 4419:【misc软件服务子系统】完善接口

Merge pull request !5592 from ester.zhou/TR-4419
# Input Method Framework # Input Method Framework
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>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. > **NOTE**<br>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.
> >
...@@ -48,9 +48,9 @@ Obtains an [InputMethodController](#InputMethodController) instance. ...@@ -48,9 +48,9 @@ Obtains an [InputMethodController](#InputMethodController) instance.
**Example** **Example**
``` ```js
var InputMethodController = inputMethod.getInputMethodController(); var InputMethodController = inputMethod.getInputMethodController();
``` ```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a> ## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
...@@ -140,18 +140,18 @@ Obtains the list of installed input methods. This API uses an asynchronous callb ...@@ -140,18 +140,18 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**Example** **Example**
```js ```js
InputMethodSetting.listInputMethod((properties)=>{ InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
console.info(property.packageName + "/" + property.methodId); console.info(property.packageName + "/" + property.methodId);
} }
}); });
``` ```
### listInputMethod ### listInputMethod
listInputMethod(): Array&lt;InputMethodProperty&gt; listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
Obtains the list of installed input methods. This API uses an asynchronous callback to return the result. Obtains the list of installed input methods. This API uses an asynchronous callback to return the result.
......
# Setting the System Time # Setting the System Time
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. This module provides the time, time zone, and timing services. Use the time and time zone services to set and obtain the system time and time zone, and use the timing service to manage and use the system time and time zone to implement alarms or other timing functions.
>
> **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -199,7 +200,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This ...@@ -199,7 +200,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
## systemTime.getRealTime<sup>8+</sup> ## systemTime.getRealTime<sup>8+</sup>
getRealTime(callback: AsyncCallback&lt;number&gt;): void getRealTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
Obtains the time elapsed since system start, including the deep sleep time. This API uses an asynchronous callback to return the result. Obtains the time elapsed since system start, including the deep sleep time. This API uses an asynchronous callback to return the result.
...@@ -227,7 +228,7 @@ Obtains the time elapsed since system start, including the deep sleep time. This ...@@ -227,7 +228,7 @@ Obtains the time elapsed since system start, including the deep sleep time. This
## systemTime.getRealTime<sup>8+</sup> ## systemTime.getRealTime<sup>8+</sup>
getRealTime(): Promise&lt;number&gt; getRealTime(isNano?: boolean): Promise&lt;number&gt;
Obtains the time elapsed since system start, including the deep sleep time. This API uses a promise to return the result. Obtains the time elapsed since system start, including the deep sleep time. This API uses a promise to return the result.
......
# Timer # Timer
> **NOTE:** The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Module to Import ## setTimeout
None
## Required Permissions ## Modules to Import
None
## setTimeout ```
import Time from '@ohos.Time';
```
setTimeout(handler[,delay[, ...args]]): number setTimeout(handler[,delay[,args]]): number
Sets a timer for the system to call a function after the timer goes off. Sets a timer for the system to call a function after the timer goes off.
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| handler | Function | Yes| Function to be called after the timer goes off.|
| delay | number | No| Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible.|
| ...args | Array&lt;any&gt; | No| Additional parameters to pass to the handler after the timer goes off.|
| Name | Type | Mandatory | Description | **Return value**
| ------- | ----------- | --------- | ------------------------------------------------------------ |
| handler | Function | Yes | Function to be called after the timer goes off. |
| delay | number | No | Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible. |
| ...args | Array\<any> | No | Additional parameter to pass to the handler after the timer goes off. |
- Return Value | Type| Description|
| -------- | -------- |
| number | Timer ID.|
**Example**
| Type | Description | ```js
| ------ | ----------- | export default {
| number | Timer ID. | setTimeOut() {
var timeoutID = setTimeout(function() {
- Example console.log('delay 1s');
}, 1000);
```
export default {
setTimeOut() {
var timeoutID = setTimeout(function() {
console.log('delay 1s');
}, 1000);
}
} }
``` }
```
## clearTimeout ## clearTimeout
...@@ -52,26 +47,25 @@ clearTimeout(timeoutID: number): void ...@@ -52,26 +47,25 @@ clearTimeout(timeoutID: number): void
Cancels the timer created via **setTimeout()**. Cancels the timer created via **setTimeout()**.
- Parameter **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timeoutID | number | Yes| ID of the timer to cancel, which is returned by **setTimeout()**|
| Name | Type | Mandatory | Description | **Example**
| --------- | ------ | --------- | ------------------------------------------------------------ |
| timeoutID | number | Yes | ID of the timer to cancel, which is returned by **setTimeout()** |
- Example ```js
export default {
``` clearTimeOut() {
export default { var timeoutID = setTimeout(function() {
clearTimeOut() { console.log('do after 1s delay.');
var timeoutID = setTimeout(function() { }, 1000);
console.log('do after 1s delay.'); clearTimeout(timeoutID);
}, 1000);
clearTimeout(timeoutID);
}
} }
``` }
```
## setInterval ## setInterval
...@@ -79,35 +73,32 @@ setInterval(handler[, delay[, ...args]]): number ...@@ -79,35 +73,32 @@ setInterval(handler[, delay[, ...args]]): number
Sets a repeating timer for the system to repeatedly call a function at a fixed interval. Sets a repeating timer for the system to repeatedly call a function at a fixed interval.
- Parameters **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| ------- | ----------- | --------- | ------------------------------------------------------------ | | -------- | -------- | -------- | -------- |
| handler | Function | Yes | Function to be called repeatedly | | handler | Function | Yes| Function to be called repeatedly.|
| delay | number | No | Number of milliseconds delayed before the execution | | delay | number | No| Number of milliseconds delayed before the execution.|
| ...args | Array\<any> | No | Additional parameter to pass to the handler after the timer goes off | | ...args | Array&lt;any&gt; | No| Additional parameters to pass to the handler after the timer goes off.|
- Return Value **Return value**
| Type| Description|
| -------- | -------- |
| number | ID of the repeating timer.|
| Type | Description | **Example**
| ------ | ------------------------- |
| number | ID of the repeated timer. |
- Example ```js
export default {
``` setInterval() {
export default { var intervalID = setInterval(function() {
setInterval() { console.log('do very 1s.');
var intervalID = setInterval(function() { }, 1000);
console.log('do very 1s.');
}, 1000);
}
} }
``` }
```
## clearInterval ## clearInterval
...@@ -115,23 +106,21 @@ clearInterval(intervalID: number): void ...@@ -115,23 +106,21 @@ clearInterval(intervalID: number): void
Cancels the repeating timer set via **setInterval()**. Cancels the repeating timer set via **setInterval()**.
- Parameter **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| ---------- | ------ | --------- | ------------------------------------------------------------ | | -------- | -------- | -------- | -------- |
| intervalID | number | Yes | ID of the repeating timer to cancel, which is returned by **setInterval()**. | | intervalID | number | Yes| ID of the repeating timer to cancel, which is returned by **setInterval()**.|
- Example **Example**
``` ```js
export default { export default {
clearInterval() { clearInterval() {
var intervalID = setInterval(function() { var intervalID = setInterval(function() {
console.log('do very 1s.'); console.log('do very 1s.');
}, 1000); }, 1000);
clearInterval(intervalID); clearInterval(intervalID);
}
} }
``` }
\ No newline at end of file ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册