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

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

Merge pull request !5592 from ester.zhou/TR-4419
# 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.
**Example**
```
var InputMethodController = inputMethod.getInputMethodController();
```
```js
var InputMethodController = inputMethod.getInputMethodController();
```
## 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
**Example**
```js
```js
InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
console.info(property.packageName + "/" + property.methodId);
}
});
```
});
```
### 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.
......
# 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
......@@ -199,7 +200,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
## 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.
......@@ -227,7 +228,7 @@ Obtains the time elapsed since system start, including the deep sleep time. This
## 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.
......
# 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
None
## Required Permissions
None
## setTimeout
setTimeout(handler[,delay[, ...args]]): number
Sets a timer for the system to call a function after the timer goes off.
## Modules to Import
- Parameters
```
import Time from '@ohos.Time';
```
setTimeout(handler[,delay[,…args]]): number
| 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\<any> | No | Additional parameter to pass to the handler after the timer goes off. |
Sets a timer for the system to call a function after the timer goes off.
- Return Value
**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.|
**Return value**
| Type | Description |
| ------ | ----------- |
| number | Timer ID. |
| Type| Description|
| -------- | -------- |
| number | Timer ID.|
- Example
**Example**
```
export default {
```js
export default {
setTimeOut() {
var timeoutID = setTimeout(function() {
console.log('delay 1s');
}, 1000);
}
}
```
}
```
## clearTimeout
......@@ -52,26 +47,25 @@ clearTimeout(timeoutID: number): void
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|
| -------- | -------- | -------- | -------- |
| timeoutID | number | Yes| ID of the timer to cancel, which is returned by **setTimeout()**|
- Example
**Example**
```
export default {
```js
export default {
clearTimeOut() {
var timeoutID = setTimeout(function() {
console.log('do after 1s delay.');
}, 1000);
clearTimeout(timeoutID);
}
}
```
}
```
## setInterval
......@@ -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.
- Parameters
| Name | Type | Mandatory | Description |
| ------- | ----------- | --------- | ------------------------------------------------------------ |
| handler | Function | Yes | Function to be called repeatedly |
| 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 |
- Return Value
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| handler | Function | Yes| Function to be called repeatedly.|
| delay | number | No| Number of milliseconds delayed before the execution.|
| ...args | Array&lt;any&gt; | No| Additional parameters to pass to the handler after the timer goes off.|
**Return value**
| Type | Description |
| ------ | ------------------------- |
| number | ID of the repeated timer. |
| Type| Description|
| -------- | -------- |
| number | ID of the repeating timer.|
- Example
**Example**
```
export default {
```js
export default {
setInterval() {
var intervalID = setInterval(function() {
console.log('do very 1s.');
}, 1000);
}
}
```
}
```
## clearInterval
......@@ -115,23 +106,21 @@ clearInterval(intervalID: number): void
Cancels the repeating timer set via **setInterval()**.
- Parameter
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| intervalID | number | Yes| ID of the repeating timer to cancel, which is returned by **setInterval()**.|
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ------------------------------------------------------------ |
| intervalID | number | Yes | ID of the repeating timer to cancel, which is returned by **setInterval()**. |
**Example**
- Example
```
export default {
```js
export default {
clearInterval() {
var intervalID = setInterval(function() {
console.log('do very 1s.');
}, 1000);
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.
先完成此消息的编辑!
想要评论请 注册