js-apis-inputmethod.md 34.7 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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
## inputMethod.switchCurrentInputMethodSubtype<sup>9+</sup>

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

选择当前的输入法子类型。

**需要权限**: 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
```

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

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

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

**需要权限**: 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 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
```

## 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

选择输入法和子类型。

**需要权限**: 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 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
```

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

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

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

**需要权限**: 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
    }
})
```

Z
zhaolinglan 已提交
638

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

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

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

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

**返回值:**

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

**示例:**

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

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

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

667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
### on('imeChange')<a name="imeChange"></a>

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;
  });
  ```

### off('imeChange')<a name="imeChange"></a>

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

查询已安装的输入法子类型列表。使用callback形式返回结果。参数个数为2,否则抛出异常。

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

**参数:**

| 参数名   | 类型                                               | 必填 | 说明                   |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| inputMethodProperty | InputMethodProperty| 是 | 要查询的输入法子类型的输入法属性
| callback | Array<[InputMethodSubtype](#InputMethodSubtype)> | 是   | 返回已安装输入法列表。 |

**示例:**

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

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

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

查询已安装的满足条件的输入法子类型列表。使用promise形式返回结果。参数个数为1,否则抛出异常。

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

**返回值:**

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

**示例:**

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

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

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

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

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

**参数:**

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

**示例:**

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

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

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

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

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

**返回值:**

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

**示例:**

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

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

getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
Z
zhaolinglan 已提交
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854

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

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

**参数:**

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

**示例:**

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

868
### getInputMethods<sup>9+</sup>
Z
zhaolinglan 已提交
869

870
getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
Z
zhaolinglan 已提交
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890

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

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

**参数:**

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

**返回值:**

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

**示例:**

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

H
Hollokin 已提交
902
### listInputMethod<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
903 904 905

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

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

H
Hollokin 已提交
908 909 910 911 912
> **说明:** 
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。

913
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
914

915
**参数:**
B
bmeangel 已提交
916

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

921
**示例:**
T
explain  
tianyu 已提交
922

923
```js
924
InputMethodSetting.listInputMethod((err,data) => {
Z
zhaolinglan 已提交
925
    if (err) {
Z
zhaolinglan 已提交
926
        console.error('listInputMethod failed because: ' + JSON.stringify(err));
927
        return;
928
    }
Z
zhaolinglan 已提交
929
    console.log('listInputMethod success');
930
 });
931
```
Z
zhouyongfei 已提交
932

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

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

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

H
Hollokin 已提交
939 940 941 942 943
> **说明:** 
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。

944
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
945

946
**返回值:**
B
bmeangel 已提交
947

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

952
**示例:**
953 954

```js
Z
zhaolinglan 已提交
955
InputMethodSetting.listInputMethod().then((data) => {
Z
zhaolinglan 已提交
956
    console.info('listInputMethod success');
Z
zhaolinglan 已提交
957
}).catch((err) => {
H
Hollokin 已提交
958
    console.error('listInputMethod promise err: ' + JSON.stringify(err));
Z
zhaolinglan 已提交
959
})
960
```
Z
zhouyongfei 已提交
961

H
Hollokin 已提交
962
### displayOptionalInputMethod<sup>(deprecated)</sup>
Z
zhouyongfei 已提交
963 964 965

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

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

H
Hollokin 已提交
968 969 970 971 972
> **说明:** 
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。

973
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
974

975
**参数:**
Z
zhouyongfei 已提交
976 977 978 979 980

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

981
**示例:**
982 983

```js
984
InputMethodSetting.displayOptionalInputMethod((err) => {
Z
zhaolinglan 已提交
985
    if (err) {
Z
zhaolinglan 已提交
986
        console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err));
987 988
        return;
    }
Z
zhaolinglan 已提交
989
    console.info('displayOptionalInputMethod success');
990
});
991
```
Z
zhouyongfei 已提交
992

993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
### 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 已提交
1012 1013 1014
try {
    InputMethodSetting.showOptionalInputMethods((err) => {
        if (err) {
H
Hollokin 已提交
1015
            console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
H
Hollokin 已提交
1016 1017 1018 1019 1020
            return;
        }
        console.info('showOptionalInputMethods success');
    });
} catch (err) {
H
Hollokin 已提交
1021
    console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
H
Hollokin 已提交
1022
}
1023 1024
```

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

1027 1028 1029 1030
displayOptionalInputMethod(): Promise&lt;void&gt;

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

H
Hollokin 已提交
1031 1032 1033 1034 1035
> **说明:** 
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。

1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
**系统能力**: 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 已提交
1057

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

1060
  **系统能力**: SystemCapability.MiscServices.InputMethodFramework
Z
zhouyongfei 已提交
1061

1062
**返回值:**
Z
zhouyongfei 已提交
1063

Z
refresh  
zhouyongfei 已提交
1064
| 类型 | 说明 |
Z
zhouyongfei 已提交
1065
| -------- | -------- |
1066
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
Z
zhouyongfei 已提交
1067

1068
**示例:**
1069 1070

```js
1071
InputMethodSetting.showOptionalInputMethods().then(() => {
Z
zhaolinglan 已提交
1072
    console.info('displayOptionalInputMethod success.(promise)');
Z
zhaolinglan 已提交
1073
}).catch((err) => {
Z
zhaolinglan 已提交
1074
    console.error('displayOptionalInputMethod promise err: ' + err);
Z
zhaolinglan 已提交
1075
})
1076
```