js-apis-inputmethod.md 35.1 KB
Newer Older
Z
zhouyongfei 已提交
1 2
# 输入法框架

T
explain  
tianyu 已提交
3 4
本模块提供对输入法框架的管理,包括隐藏输入法、查询已安装的输入法列表和显示输入法选择对话框。

5
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
6
>
Z
zhouyongfei 已提交
7 8 9 10 11 12
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。


## 导入模块

```
13
import inputMethod from '@ohos.inputmethod';
Z
zhouyongfei 已提交
14 15 16 17 18 19
```

## inputMethod<sup>8+</sup>

常量值。

20
**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework
Z
刷新  
zhouyongfei 已提交
21

Z
zhouyongfei 已提交
22 23
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
Z
刷新  
zhouyongfei 已提交
24
| MAX_TYPE_NUM | number | 是 | 否 | 可支持的最大输入法个数。 |
Z
zhouyongfei 已提交
25 26


27
## InputMethodProperty<sup>8+</sup>
Z
zhouyongfei 已提交
28 29 30

输入法应用属性。

31
**系统能力**:以下各项对应的系统能力均为SystemCapability.MiscServices.InputMethodFramework
Z
刷新  
zhouyongfei 已提交
32

Z
zhouyongfei 已提交
33 34
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
H
Hollokin 已提交
35 36
| packageName<sup>(deprecated)</sup> | string | 是 | 否 | 包名。 |
| methodId<sup>(deprecated)</sup> | string | 是 | 否 | Ability名。 |
H
Hollokin 已提交
37 38 39 40 41 42
| name<sup>9+</sup>  | string | 是 | 否 | 包名,非必填项。 |
| id<sup>9+</sup>    | string | 是 | 否 | Ability名,非必填项。 |
| label<sup>9+</sup>    | string | 是 | 否 | 输入法标签,非必填项。| 
| icon<sup>9+</sup>    | string | 是 | 否 | 输入法图标,非必填项。 |
| iconId<sup>9+</sup>    | number | 是 | 否 | 输入法图标id,非必填项。 |
| extra<sup>9+</sup>    | object | 是 | 否 | 输入法其他信息,非必填项。 |
Z
zhouyongfei 已提交
43

H
Hollokin 已提交
44
## inputMethod.getInputMethodController<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
45 46 47

getInputMethodController(): InputMethodController

48
获取客户端实例[InputMethodController](#inputmethodcontroller)
Z
zhouyongfei 已提交
49

50 51 52 53 54
> **说明:** 
> 从API version 9开始废弃, 建议使用[getController](#getController)替代
>
> 从 API version 6开始支持。

55
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
56

57
**返回值:**
Z
zhouyongfei 已提交
58

59 60 61
| 类型                                            | 说明                     |
| ----------------------------------------------- | ------------------------ |
| [InputMethodController](#inputmethodcontroller) | 回调返回当前客户端实例。 |
Z
zhouyongfei 已提交
62

63
**示例:**
T
explain  
tianyu 已提交
64

65
```js
Z
zhouyongfei 已提交
66
  var InputMethodController = inputMethod.getInputMethodController();
67
```
68

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
## inputMethod.getController<sup>9+</sup>

getController(): InputMethodController

获取客户端实例[InputMethodController](#inputmethodcontroller)

**系统能力**:SystemCapability.MiscServices.InputMethodFramework

**返回值:**

| 类型                                            | 说明                     |
| ----------------------------------------------- | ------------------------ |
| [InputMethodController](#inputmethodcontroller) | 回调返回当前客户端实例。 |

**示例:**

```js
  var InputMethodController = inputMethod.getController();
```

H
Hollokin 已提交
89
## inputMethod.getInputMethodSetting<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
90 91 92

getInputMethodSetting(): InputMethodSetting

93
获取客户端设置实例[InputMethodSetting](#inputmethodsetting8)
Z
zhouyongfei 已提交
94

H
Hollokin 已提交
95 96 97 98 99
> **说明:** 
> 从API version 9开始废弃, 建议使用[getSetting](#getSetting)替代
>
> 从 API version 6开始支持。

100
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
101

102
**返回值:**
Z
zhouyongfei 已提交
103

T
explain  
tianyu 已提交
104 105
| 类型                                      | 说明                         |
| ----------------------------------------- | ---------------------------- |
106
| [InputMethodSetting](#inputmethodsetting8) | 回调返回当前客户端设置实例。 |
Z
zhouyongfei 已提交
107 108


109
**示例:**
110 111

```js
Z
zhouyongfei 已提交
112
  var InputMethodSetting = inputMethod.getInputMethodSetting();
113
```
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

## inputMethod.getSetting<sup>9+</sup>

getSetting(): InputMethodSetting

获取客户端设置实例[InputMethodSetting](#inputmethodsetting8)

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**返回值:**

| 类型                                      | 说明                         |
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#inputmethodsetting8) | 回调返回当前客户端设置实例。 |


**示例:**

```js
  var InputMethodSetting = inputMethod.getSetting();
```

G
gaoxiang 已提交
136
## inputMethod.switchInputMethod<sup>9+</sup>
Z
zhouyongfei 已提交
137

Z
zhaolinglan 已提交
138
switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolean&gt;): void
G
gaoxiang 已提交
139

140
切换输入法。此接口仅可在Stage模型下使用。使用callback形式返回结果。参数个数为2,否则抛出异常。
141

142 143
**需要权限**: ohos.permission.CONNECT_IME_ABILITY

Z
zhaolinglan 已提交
144
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
G
gaoxiang 已提交
145 146 147 148 149

**参数:**

  | 参数名 | 类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
G
gaoxiang 已提交
150
  |target | [InputmethodProperty](#inputmethodproperty8) | 是 | 传入要切换的目标输入法。 |
G
gaoxiang 已提交
151 152 153 154 155 156
  | callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法切换是否成功。 |


**示例:**

```js
H
Hollokin 已提交
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
try{
    inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}, (err, result) => {
        if (err) {
            // 处理业务逻辑执行错误
            console.error('switchInputMethod err: ' + JSON.stringify(err));
            return;
        }
        if (result) {
            console.info('Success to switchInputMethod.(callback)');
        } else {
            console.error('Failed to switchInputMethod.(callback)');
        }
    });
} catch(err) {
    // 捕获参数错误
H
Hollokin 已提交
172
    console.error('switchInputMethod err: ' + JSON.stringify(err));
H
Hollokin 已提交
173
}
G
gaoxiang 已提交
174
```
G
gaoxiang 已提交
175
## inputMethod.switchInputMethod<sup>9+</sup>
Z
zhaolinglan 已提交
176
switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
G
gaoxiang 已提交
177

178
切换输入法。此接口仅可在Stage模型下使用。使用promise形式返回结果。参数个数为1,否则抛出异常。
G
gaoxiang 已提交
179

180 181
**需要权限**: ohos.permission.CONNECT_IME_ABILITY

Z
zhaolinglan 已提交
182
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
G
gaoxiang 已提交
183

G
gaoxiang 已提交
184
**参数:**
G
gaoxiang 已提交
185 186 187

  | 参数名 | 类型 | 必填 | 说明 |
  | -------- | -------- | -------- | -------- |
G
gaoxiang 已提交
188
  |target |  [InputmethodProperty](#inputmethodproperty8)| 是 | 传入要切换的目标输入法。 |
G
gaoxiang 已提交
189

G
gaoxiang 已提交
190
**返回值:**
B
bmeangel 已提交
191

G
gaoxiang 已提交
192 193
  | 类型                                      | 说明                         |
  | ----------------------------------------- | ---------------------------- |
194
  | Promise\<boolean> | 回调返回切换后的输入法。 |
G
gaoxiang 已提交
195

G
gaoxiang 已提交
196 197 198
**示例:**

```js
H
Hollokin 已提交
199 200 201 202 203 204 205 206
try {
    inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}).then((result) => {
        if (result) {
            console.info('Success to switchInputMethod.(promise)');
        } else {
            console.error('Failed to switchInputMethod.(promise)');
        }
    }).catch((err) => {
H
Hollokin 已提交
207
        console.error('switchInputMethod promise err: ' + JSON.stringify(err));
H
Hollokin 已提交
208 209
    })
} catch(err) {
H
Hollokin 已提交
210
    console.error('switchInputMethod err: ' + JSON.stringify(err));
H
Hollokin 已提交
211
}
G
gaoxiang 已提交
212
```
213

Z
zhaolinglan 已提交
214 215 216 217
## inputMethod.getCurrentInputMethod<sup>9+</sup>

getCurrentInputMethod(): InputMethodProperty

Z
zhaolinglan 已提交
218
获取当前输入法扩展应用,提供同步接口,返回当前输入法属性对象。
Z
zhaolinglan 已提交
219 220 221 222 223

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**返回值:**

Z
zhaolinglan 已提交
224 225 226
| 类型                                         | 说明                     |
| -------------------------------------------- | ------------------------ |
| [InputmethodProperty](#inputmethodproperty8) | 返回当前输入法属性对象。 |
Z
zhaolinglan 已提交
227 228 229 230 231 232 233

**示例:**

```js
var currentIme = inputMethod.getCurrentInputMethod();
```

234 235 236 237
## inputMethod.switchCurrentInputMethodSubtype<sup>9+</sup>

switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback<boolean>): void

H
Hollokin 已提交
238
在当前输入法应用内切换子类型。
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253

**需要权限**: ohos.permission.CONNECT_IME_ABILITY

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|target |  [InputMethodSubtype](#InputMethodSubtype)| 是 | 传入要切换的目标输入法子类型。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法子类型切换是否成功。 |

**示例:**

```js
H
Hollokin 已提交
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
let inputMethodSubProperty = {
    id: "com.example.kikainput",
    label: "ServiceExtAbility"
}
try {
    inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err, result) => {
        if (err) {
            console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
            return;
        }
        if (result) {
            console.info('Success to switchCurrentInputMethodSubtype.(callback)');
        } else {
            console.error('Failed to switchCurrentInputMethodSubtype.(callback)');
        }
    });
} catch(err) {
H
Hollokin 已提交
271
    console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
272
}
273 274 275 276 277 278
```

## inputMethod.switchCurrentInputMethodSubtype<sup>9+</sup>

switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&gt;

H
Hollokin 已提交
279
在当前输入法应用内切换子类型。此接口仅可在Stage模型下使用。使用promise形式返回结果。参数个数为1,否则抛出异常。
280 281 282 283 284 285 286 287 288 289 290 291 292 293

**需要权限**: ohos.permission.CONNECT_IME_ABILITY

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|target |  [InputMethodSubtype](#InputMethodSubtype)| 是 | 传入要切换的目标输入法子类型。 |

**示例:**

```js
H
Hollokin 已提交
294 295 296 297 298 299 300 301 302 303 304 305
let inputMethodSubProperty = {
    id: "com.example.kikainput",
    label: "ServiceExtAbility"
}
try {
    inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((result) => {
        if (result) {
            console.info('Success to switchCurrentInputMethodSubtype.(promise)');
        } else {
            console.error('Failed to switchCurrentInputMethodSubtype.(promise)');
        }
    }).catch((err) => {
H
Hollokin 已提交
306
        console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
307 308
    })
} catch(err) {
H
Hollokin 已提交
309
    console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
310
}
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
```

## inputMethod.getCurrentInputMethodSubtype<sup>9+</sup>

getCurrentInputMethodSubtype(): InputMethodSubtype

获取当前输入法子类型。

**需要权限**: ohos.permission.CONNECT_IME_ABILITY

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**返回值:**

| 类型                                         | 说明                     |
| -------------------------------------------- | ------------------------ |
| [InputMethodSubtype](#InputMethodSubtype) | 返回当前输入法子类型对象。 |

**示例:**

```js
var currentImeSubType = inputMethod.getCurrentInputMethodSubtype();
```

## inputMethod.switchCurrentInputMethodAndSubtype<sup>9+</sup>

switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback<boolean>): void

H
Hollokin 已提交
339
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355

**需要权限**: ohos.permission.CONNECT_IME_ABILITY

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|inputMethodProperty |  [InputMethodProperty](#InputMethodProperty)| 是 | 传入要切换的目标输入法。 |
|inputMethodSubtype |  [inputMethodSubtype](#InputMethodSubtype)| 是 | 传入要切换的目标输入法子类型。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法和子类型切换是否成功。 |

**示例:**

```js
H
Hollokin 已提交
356 357 358 359
let inputMethodProperty = {
    packageName:"com.example.kikakeyboard",
    methodId:"ServiceExtAbility"
}
H
Hollokin 已提交
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
let inputMethodSubProperty = {
    id: "com.example.kikainput",
    label: "ServiceExtAbility"
}
try {
    inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,result) => {
        if (err) {
            console.error('switchCurrentInputMethodAndSubtype err: ' + JSON.stringify(err));
            return;
        }
        if (result) {
            console.info('Success to switchCurrentInputMethodAndSubtype.(callback)');
        } else {
            console.error('Failed to switchCurrentInputMethodAndSubtype.(callback)');
        }
    });
} catch (err) {
H
Hollokin 已提交
377
    console.error('switchCurrentInputMethodAndSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
378
}
379 380 381 382 383 384
```

## inputMethod.switchCurrentInputMethodAndSubtype<sup>9+</sup>

switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, ): Promise&lt;boolean&gt;

H
Hollokin 已提交
385
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。参数个数为1,否则抛出异常。
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400

**需要权限**: ohos.permission.CONNECT_IME_ABILITY

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|inputMethodProperty |  [InputMethodProperty](#InputMethodProperty)| 是 | 传入要切换的目标输入法。 |
|inputMethodSubtype |  [inputMethodSubtype](#InputMethodSubtype)| 是 | 传入要切换的目标输入法子类型。 |

**示例:**

```js
H
Hollokin 已提交
401 402 403 404
let inputMethodProperty = {
    packageName:"com.example.kikakeyboard",
    methodId:"ServiceExtAbility"
}
H
Hollokin 已提交
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
let inputMethodSubProperty = {
    id: "com.example.kikainput",
    label: "ServiceExtAbility"
}
try {
    inputMethod.switchCurrentInputMethodAndSubtype(property, subType).then((result) => {
        if (result) {
            console.info('Success to switchCurrentInputMethodAndSubtype.(promise)');
        } else {
            console.error('Failed to switchCurrentInputMethodAndSubtype.(promise)');
        }
    }).catch((err) => {
        console.error('switchCurrentInputMethodAndSubtype promise err: ' + err);
    })
} catch(err) {
H
Hollokin 已提交
420
    console.error('switchCurrentInputMethodAndSubtype promise err: ' + err);
H
Hollokin 已提交
421
}
422 423
```

424
## InputMethodController
Z
zhouyongfei 已提交
425

H
Hollokin 已提交
426
下列API示例中都需使用[getController](#inputmethodgetcontroller)回调获取到InputMethodController实例,再通过此实例调用对应方法。
Z
zhouyongfei 已提交
427

H
Hollokin 已提交
428
### stopInput<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
429 430 431

stopInput(callback: AsyncCallback&lt;boolean&gt;): void

432
隐藏输入法。使用callback形式返回结果。参数个数为1,否则抛出异常。
Z
zhouyongfei 已提交
433

H
Hollokin 已提交
434 435 436 437 438
> **说明:** 
> 从API version 9开始废弃, 建议使用[stopInputSession](#stopInputSession)替代
>
> 从 API version 6开始支持。

439
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
440

441
**参数:**
Z
zhouyongfei 已提交
442

T
explain  
tianyu 已提交
443 444 445
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法隐藏是否成功。 |
Z
zhouyongfei 已提交
446

447
**示例:**
Z
zhouyongfei 已提交
448

449
```js
Z
zhaolinglan 已提交
450
InputMethodController.stopInput((error, result) => {
Z
zhaolinglan 已提交
451
    if (error) {
Z
zhaolinglan 已提交
452
        console.error('failed to stopInput because: ' + JSON.stringify(error));
453 454
        return;
    }
Z
zhaolinglan 已提交
455
    if (result) {
Z
zhaolinglan 已提交
456
        console.info('Success to stopInput.(callback)');
Z
zhaolinglan 已提交
457
    } else {
Z
zhaolinglan 已提交
458
        console.error('Failed to stopInput.(callback)');
Z
zhaolinglan 已提交
459
    }
460
});
Z
zhouyongfei 已提交
461 462
```

H
Hollokin 已提交
463
### stopInput<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
464 465 466

stopInput(): Promise&lt;boolean&gt;

467
隐藏输入法。使用promise形式返回结果。参数个数为0,否则抛出异常。
Z
zhouyongfei 已提交
468

H
Hollokin 已提交
469 470 471 472 473
> **说明:** 
> 从API version 9开始废弃, 建议使用[stopInputSession](#stopInputSession)替代
>
> 从 API version 6开始支持。

474
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
475

476
**返回值:**
Z
zhouyongfei 已提交
477

T
explain  
tianyu 已提交
478 479 480
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 返回输入法隐藏是否成功。 |
Z
zhouyongfei 已提交
481

482
**示例:**
Z
zhouyongfei 已提交
483

484
```js
Z
zhaolinglan 已提交
485 486
InputMethodController.stopInput().then((result) => {
    if (result) {
Z
zhaolinglan 已提交
487
        console.info('Success to stopInput.(promise)');
Z
zhaolinglan 已提交
488
    } else {
Z
zhaolinglan 已提交
489
        console.error('Failed to stopInput.(promise)');
Z
zhaolinglan 已提交
490 491
    }
}).catch((err) => {
Z
zhaolinglan 已提交
492
    console.error('stopInput promise err: ' + err);
Z
zhaolinglan 已提交
493
})
Z
zhouyongfei 已提交
494 495
```

496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
### stopInputSession<sup>9+</sup>

stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void

隐藏输入法。使用callback形式返回结果。参数个数为1,否则抛出异常。

**系统能力**:SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法隐藏是否成功。 |

**示例:**

```js
H
Hollokin 已提交
513 514 515
try {
    InputMethodController.stopInputSession((error, result) => {
        if (error) {
H
Hollokin 已提交
516
            console.error('stopInputSession err: ' + JSON.stringify(error));
H
Hollokin 已提交
517 518 519 520 521 522 523 524
            return;
        }
        if (result) {
            console.info('Success to stopInputSession.(callback)');
        } else {
            console.error('Failed to stopInputSession.(callback)');
        }
    });
H
Hollokin 已提交
525 526
} catch(error) {
    console.error('stopInputSession err: ' + JSON.stringify(error));
H
Hollokin 已提交
527
}
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
```

### stopInputSession

stopInputSession(): Promise&lt;boolean&gt;

隐藏输入法。使用promise形式返回结果。参数个数为0,否则抛出异常。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**返回值:**

| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 返回输入法隐藏是否成功。 |

**示例:**

```js
H
Hollokin 已提交
547 548 549 550 551 552 553 554
try {
    InputMethodController.stopInputSession().then((result) => {
        if (result) {
            console.info('Success to stopInputSession.(promise)');
        } else {
            console.error('Failed to stopInputSession.(promise)');
        }
    }).catch((err) => {
H
Hollokin 已提交
555
        console.error('stopInputSession err: ' + JSON.stringify(err));
H
Hollokin 已提交
556 557
    })
} catch(err) {
H
Hollokin 已提交
558
    console.error('stopInputSession err: ' + JSON.stringify(err));
H
Hollokin 已提交
559
}
560 561
```

Z
zhaolinglan 已提交
562
### showSoftKeyboard<sup>9+</sup> ###
Z
zhaolinglan 已提交
563

Z
zhaolinglan 已提交
564
showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
Z
zhaolinglan 已提交
565

566
显示软键盘,使用callback异步回调。参数个数为1,否则抛出异常。
Z
zhaolinglan 已提交
567

Z
zhaolinglan 已提交
568
**系统能力:**  SystemCapability.MiscServices.InputMethodFramework
Z
zhaolinglan 已提交
569 570 571

**参数:**

Z
zhaolinglan 已提交
572
| 参数名   | 参数类型                  | 必填 | 说明       |
Z
zhaolinglan 已提交
573 574
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
Z
zhaolinglan 已提交
575 576 577 578

**示例:**

```js
Z
zhaolinglan 已提交
579
InputMethodController.showSoftKeyboard((err) => {
Z
zhaolinglan 已提交
580
    if (err === undefined) {
Z
zhaolinglan 已提交
581
        console.info('showSoftKeyboard success');
Z
zhaolinglan 已提交
582
    } else {
Z
zhaolinglan 已提交
583
        console.error('showSoftKeyboard failed because : ' + JSON.stringify(err));
Z
zhaolinglan 已提交
584 585 586 587
    }
})
```

Z
zhaolinglan 已提交
588
### showSoftKeyboard<sup>9+</sup> ###
Z
zhaolinglan 已提交
589

Z
zhaolinglan 已提交
590
showSoftKeyboard(): Promise&lt;void&gt;
Z
zhaolinglan 已提交
591

592
显示软键盘,使用Promise异步回调。参数个数为0,否则抛出异常。
Z
zhaolinglan 已提交
593

Z
zhaolinglan 已提交
594
**系统能力:**  SystemCapability.MiscServices.InputMethodFramework
Z
zhaolinglan 已提交
595 596 597

**返回值:**

Z
zhaolinglan 已提交
598 599 600
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
zhaolinglan 已提交
601 602 603 604

**示例:**

```js
Z
zhaolinglan 已提交
605 606 607
InputMethodController.showSoftKeyboard().then(async (err) => {
    console.log('showSoftKeyboard success');
}).catch((err) => {
Z
zhaolinglan 已提交
608
    console.error('showSoftKeyboard promise err: ' + JSON.stringify(err));
Z
zhaolinglan 已提交
609 610 611
});
```

Z
zhaolinglan 已提交
612
### hideSoftKeyboard<sup>9+</sup> ###
Z
zhaolinglan 已提交
613

Z
zhaolinglan 已提交
614
hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
Z
zhaolinglan 已提交
615

616
隐藏软键盘,使用callback异步回调。参数个数为1,否则抛出异常。
Z
zhaolinglan 已提交
617

Z
zhaolinglan 已提交
618
**系统能力:**  SystemCapability.MiscServices.InputMethodFramework
Z
zhaolinglan 已提交
619 620 621

**参数:**

Z
zhaolinglan 已提交
622 623 624
| 参数名   | 参数类型                  | 必填 | 说明       |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
Z
zhaolinglan 已提交
625 626 627 628

**示例:**

```js
Z
zhaolinglan 已提交
629
InputMethodController.hideSoftKeyboard((err) => {
Z
zhaolinglan 已提交
630
    if (err === undefined) {
Z
zhaolinglan 已提交
631
        console.info('hideSoftKeyboard success');
Z
zhaolinglan 已提交
632
    } else {
Z
zhaolinglan 已提交
633
        console.error('hideSoftKeyboard failed because : ' + JSON.stringify(err));
Z
zhaolinglan 已提交
634 635 636 637
    }
})
```

638
### hideSoftKeyboard<sup>9+</sup>
Z
zhaolinglan 已提交
639

Z
zhaolinglan 已提交
640
hideSoftKeyboard(): Promise&lt;void&gt;
Z
zhaolinglan 已提交
641

642
隐藏软键盘,使用Promise异步回调。参数个数为0,否则抛出异常。
Z
zhaolinglan 已提交
643

Z
zhaolinglan 已提交
644
**系统能力:**  SystemCapability.MiscServices.InputMethodFramework
Z
zhaolinglan 已提交
645 646 647

**返回值:**

Z
zhaolinglan 已提交
648 649 650
| 类型                | 说明                      |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
zhaolinglan 已提交
651 652 653 654

**示例:**

```js
Z
zhaolinglan 已提交
655 656 657
InputMethodController.hideSoftKeyboard().then(async (err) => {
    console.log('hideSoftKeyboard success');
}).catch((err) => {
Z
zhaolinglan 已提交
658
    console.error('hideSoftKeyboard promise err: ' + JSON.stringify(err));
Z
zhaolinglan 已提交
659 660 661
});
```

662
## InputMethodSetting<sup>8+</sup>
Z
zhouyongfei 已提交
663

H
Hollokin 已提交
664
下列API示例中都需使用[getSetting](#inputmethodgetsetting)回调获取到InputMethodSetting实例,再通过此实例调用对应方法。
Z
zhouyongfei 已提交
665

666
### on('imeChange')<a name="imeChange"></a><sup>9+</sup>
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689

on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void

订阅输入法及子类型变化监听事件,使用callback回调返回变化了的输入法及子类型的相关实例。参数个数为3,参数1和参数2为napi_object,参数3为napi_function,否则抛出异常。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名   | 类型                            | 必填 | 说明                                                         |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                        | 是   | 设置监听类型。<br/>-type为‘imeChange’时表示订阅输入法及子类型变化监听事件。 |
| callback | [inputMethodProperty](#InputMethodProperty), [inputMethodSubtype](#InputMethodSubtype) | 是 | 回调返回输入法及子类型相关实例。 |

**示例:**

  ```js
  InputMethodEngine.on('imeChange', (inputMethodProperty, inputMethodSubtype) => {
      InputMethodProperty = inputMethodProperty;
      InputMethodSubtype = inputMethodSubtype;
  });
  ```

H
Hollokin 已提交
690
### off('imeChange')<a name="imeChange"></a><sup>9+</sup>
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714

on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void

取消订阅输入法及子类型变化监听事件,使用callback回调返回取消订阅的输入法及子类型的相关实例。必选参数个数为1,参数1为string,可选参数2为napi_function,否则抛出异常。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名   | 类型                            | 必填 | 说明                                                         |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type     | string                        | 是   | 设置监听类型。<br/>-type为‘imeChange’时表示取消订阅输入法及子类型变化监听事件。 |
| callback | [inputMethodProperty](#InputMethodProperty), [inputMethodSubtype](#InputMethodSubtype) | 否 | 回调返回输入法及子类型相关实例。 |

**示例:**

  ```js
  InputMethodAbility.off('imeChange');
  ```

### listInputMethodSubtype<sup>9+</sup>

listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void

H
Hollokin 已提交
715
获取指定输入法应用的所有子类型。使用callback形式返回结果。参数个数为2,否则抛出异常。
716 717 718 719 720 721 722

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名   | 类型                                               | 必填 | 说明                   |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
H
Hollokin 已提交
723
| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用
724 725 726 727 728
| callback | Array<[InputMethodSubtype](#InputMethodSubtype)> | 是   | 返回已安装输入法列表。 |

**示例:**

```js
H
Hollokin 已提交
729 730 731 732 733 734 735
let inputMethodSubProperty = {
    id: "com.example.kikainput",
    label: "ServiceExtAbility"
}
try {
    InputMethodSetting.listInputMethodSubtype(inputMethodSubProperty, (err,data) => {
        if (err) {
H
Hollokin 已提交
736
            console.error('listInputMethodSubtype failed: ' + JSON.stringify(err));
H
Hollokin 已提交
737 738 739 740 741
            return;
        }
        console.log('listInputMethodSubtype success');
    });
} catch (err) {
H
Hollokin 已提交
742
    console.error('listInputMethodSubtype failed: ' + JSON.stringify(err));
H
Hollokin 已提交
743
}
744 745 746 747 748 749
```

### listInputMethodSubtype<sup>9+</sup>

listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;

H
Hollokin 已提交
750
获取指定输入法应用的所有子类型。使用promise形式返回结果。参数个数为1,否则抛出异常。
751 752 753

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

H
Hollokin 已提交
754 755 756 757 758 759
**参数:**

| 参数名   | 类型                                               | 必填 | 说明                   |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用

760 761 762 763 764 765 766 767 768
**返回值:**

| 类型                                                        | 说明                   |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](#InputMethodSubtype)>> | 返回已安装输入法子类型列表。 |

**示例:**

```js
H
Hollokin 已提交
769 770 771 772 773 774 775 776
let inputMethodSubProperty = {
    id: "com.example.kikainput",
    label: "ServiceExtAbility"
}
try {
    InputMethodSetting.listInputMethodSubtype(inputMethodSubProperty).then((data) => {
        console.info('listInputMethodSubtype success');
    }).catch((err) => {
H
Hollokin 已提交
777
        console.error('listInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
778 779
    })
} catch(err) {
H
Hollokin 已提交
780
    console.error('listInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
781
}
782 783 784 785 786
```

### listCurrentInputMethodSubtype<sup>9+</sup>

listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void
Z
zhaolinglan 已提交
787

788 789 790 791 792 793 794 795 796 797 798 799 800
查询当前输入法的子类型列表。使用callback形式返回结果。参数个数为1,否则抛出异常。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名   | 类型                                               | 必填 | 说明                   |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodSubtype](#InputMethodSubtype)> | 是   | 返回当前输入法的子类型列表。 |

**示例:**

```js
H
Hollokin 已提交
801
try {
H
Hollokin 已提交
802
    InputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
H
Hollokin 已提交
803
        if (err) {
H
Hollokin 已提交
804
            console.error('listCurrentInputMethodSubtype failed: ' + JSON.stringify(err));
H
Hollokin 已提交
805 806 807 808 809
            return;
        }
        console.log('listCurrentInputMethodSubtype success');
    });
} catch(err) {
H
Hollokin 已提交
810
    console.error('listCurrentInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
811
}
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
```

### listCurrentInputMethodSubtype<sup>9+</sup>

listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;

查询当前输入法的子类型列表。使用promise形式返回结果。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**返回值:**

| 类型                                                        | 说明                   |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](#InputMethodSubtype)>> | 返回当前输入法的子类型列表。 |

**示例:**

```js
H
Hollokin 已提交
831 832 833 834 835 836 837
try {
    InputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
        console.info('listCurrentInputMethodSubtype success');
    }).catch((err) => {
        console.error('listCurrentInputMethodSubtype promise err: ' + err);
    })
} catch(err) {
H
Hollokin 已提交
838
    console.error('listCurrentInputMethodSubtype err: ' + JSON.stringify(err));
H
Hollokin 已提交
839
}
840 841 842 843 844
```

### getInputMethods<sup>9+</sup>

getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
Z
zhaolinglan 已提交
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859

获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。使用callback形式返回结果。参数个数为2,否则抛出异常。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名   | 类型                                                | 必填 | 说明                          |
| -------- | --------------------------------------------------- | ---- | ----------------------------- |
| enable   | boolean                                             | 是   | 指定返回已激活/未激活。       |
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | 是   | 返回已激活/未激活输入法列表。 |

**示例:**

```js
H
Hollokin 已提交
860 861 862
try {
    InputMethodSetting.getInputMethods(true, (err,data) => {
        if (err) {
H
Hollokin 已提交
863
            console.error('getInputMethods failed: ' + JSON.stringify(err));
H
Hollokin 已提交
864 865 866 867 868
            return;
        }
        console.log('getInputMethods success');
    });
} catch (err) {
H
Hollokin 已提交
869
    console.error('getInputMethods failed: ' + JSON.stringify(err));
H
Hollokin 已提交
870
}
Z
zhaolinglan 已提交
871 872
```

873
### getInputMethods<sup>9+</sup>
Z
zhaolinglan 已提交
874

875
getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
Z
zhaolinglan 已提交
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895

获取已激活/未激活输入法列表。参数enable取true返回已激活输入法列表,取false返回未激活输入法列表。使用promise形式返回结果。参数个数为0,否则抛出异常。

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型    | 必填 | 说明                    |
| ------ | ------- | ---- | ----------------------- |
| enable | boolean | 是   | 指定返回已激活/未激活。 |

**返回值:**

| 类型                                                         | 说明                          |
| ------------------------------------------------------------ | ----------------------------- |
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | 返回已激活/未激活输入法列表。 |

**示例:**

```js
H
Hollokin 已提交
896 897 898 899
try {
    InputMethodSetting.getInputMethods(true).then((data) => {
        console.info('getInputMethods success');
    }).catch((err) => {
H
Hollokin 已提交
900
        console.error('getInputMethods promise err: ' + JSON.stringify(err));
H
Hollokin 已提交
901 902
    })
} catch(err) {
H
Hollokin 已提交
903
    console.error('getInputMethods promise err: ' + JSON.stringify(err));
H
Hollokin 已提交
904
}
Z
zhaolinglan 已提交
905 906
```

H
Hollokin 已提交
907
### listInputMethod<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
908 909 910

listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void

911
查询已安装的输入法列表。使用callback形式返回结果。参数个数为1,否则抛出异常。
Z
zhouyongfei 已提交
912

H
Hollokin 已提交
913 914 915 916 917
> **说明:** 
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。

918
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
919

920
**参数:**
B
bmeangel 已提交
921

T
explain  
tianyu 已提交
922 923
| 参数名   | 类型                                               | 必填 | 说明                   |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
924
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | 是   | 返回已安装输入法列表。 |
Z
zhouyongfei 已提交
925

926
**示例:**
T
explain  
tianyu 已提交
927

928
```js
929
InputMethodSetting.listInputMethod((err,data) => {
Z
zhaolinglan 已提交
930
    if (err) {
Z
zhaolinglan 已提交
931
        console.error('listInputMethod failed because: ' + JSON.stringify(err));
932
        return;
933
    }
Z
zhaolinglan 已提交
934
    console.log('listInputMethod success');
935
 });
936
```
Z
zhouyongfei 已提交
937

H
Hollokin 已提交
938
### listInputMethod<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
939

Z
zhaolinglan 已提交
940
listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
Z
zhouyongfei 已提交
941

942
查询已安装的输入法列表。使用promise形式返回结果。参数个数为0,否则抛出异常。
Z
zhouyongfei 已提交
943

H
Hollokin 已提交
944 945 946 947 948
> **说明:** 
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。

949
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
950

951
**返回值:**
B
bmeangel 已提交
952

T
explain  
tianyu 已提交
953 954
| 类型                                                        | 说明                   |
| ----------------------------------------------------------- | ---------------------- |
955
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | 返回已安装输入法列表。 |
Z
zhouyongfei 已提交
956

957
**示例:**
958 959

```js
Z
zhaolinglan 已提交
960
InputMethodSetting.listInputMethod().then((data) => {
Z
zhaolinglan 已提交
961
    console.info('listInputMethod success');
Z
zhaolinglan 已提交
962
}).catch((err) => {
H
Hollokin 已提交
963
    console.error('listInputMethod promise err: ' + JSON.stringify(err));
Z
zhaolinglan 已提交
964
})
965
```
Z
zhouyongfei 已提交
966

H
Hollokin 已提交
967
### displayOptionalInputMethod<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
968 969 970

displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void

971
显示输入法选择对话框。使用callback形式返回结果。参数个数为1,否则抛出异常。
Z
zhouyongfei 已提交
972

H
Hollokin 已提交
973 974 975 976 977
> **说明:** 
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。

978
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
979

980
**参数:**
Z
zhouyongfei 已提交
981 982 983 984 985

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |

986
**示例:**
987 988

```js
989
InputMethodSetting.displayOptionalInputMethod((err) => {
Z
zhaolinglan 已提交
990
    if (err) {
Z
zhaolinglan 已提交
991
        console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err));
992 993
        return;
    }
Z
zhaolinglan 已提交
994
    console.info('displayOptionalInputMethod success');
995
});
996
```
Z
zhouyongfei 已提交
997

998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
### showOptionalInputMethods<sup>9+</sup>

showOptionalInputMethods(callback: AsyncCallback&lt;void&gt;): void

显示输入法选择对话框。使用callback形式返回结果。参数个数为1,否则抛出异常。

**需要权限**: ohos.permission.CONNECT_IME_ABILITY

**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |

**示例:**

```js
H
Hollokin 已提交
1017 1018 1019
try {
    InputMethodSetting.showOptionalInputMethods((err) => {
        if (err) {
H
Hollokin 已提交
1020
            console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
H
Hollokin 已提交
1021 1022 1023 1024 1025
            return;
        }
        console.info('showOptionalInputMethods success');
    });
} catch (err) {
H
Hollokin 已提交
1026
    console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
H
Hollokin 已提交
1027
}
1028 1029
```

H
Hollokin 已提交
1030
### displayOptionalInputMethod<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
1031

1032 1033 1034 1035
displayOptionalInputMethod(): Promise&lt;void&gt;

显示输入法选择对话框。使用promise形式返回结果。参数个数为0,否则抛出异常。

H
Hollokin 已提交
1036 1037 1038 1039 1040
> **说明:** 
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。

1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
**系统能力**: SystemCapability.MiscServices.InputMethodFramework

**返回值:**

| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |

**示例:**

```js
InputMethodSetting.displayOptionalInputMethod().then(() => {
    console.info('displayOptionalInputMethod success.(promise)');
}).catch((err) => {
    console.error('displayOptionalInputMethod promise err: ' + err);
})
```

### showOptionalInputMethods<sup>9+</sup>

  showOptionalInputMethods(): Promise&lt;void&gt;
Z
zhouyongfei 已提交
1062

1063
  显示输入法选择对话框。使用promise形式返回结果。参数个数为0,否则抛出异常。
Z
zhouyongfei 已提交
1064

1065
  **系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
1066

1067
**返回值:**
Z
zhouyongfei 已提交
1068

Z
refresh  
zhouyongfei 已提交
1069
| 类型 | 说明 |
Z
zhouyongfei 已提交
1070
| -------- | -------- |
1071
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
zhouyongfei 已提交
1072

1073
**示例:**
1074 1075

```js
1076
InputMethodSetting.showOptionalInputMethods().then(() => {
Z
zhaolinglan 已提交
1077
    console.info('displayOptionalInputMethod success.(promise)');
Z
zhaolinglan 已提交
1078
}).catch((err) => {
Z
zhaolinglan 已提交
1079
    console.error('displayOptionalInputMethod promise err: ' + err);
Z
zhaolinglan 已提交
1080
})
1081
```