js-apis-inputmethod-extension-ability.md 1.9 KB
Newer Older
E
ester.zhou 已提交
1
# @ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)
E
ester.zhou 已提交
2

E
ester.zhou 已提交
3
The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles.
E
ester.zhou 已提交
4 5

> **NOTE**
E
ester.zhou 已提交
6
>
E
ester.zhou 已提交
7 8 9 10
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

## Modules to Import

E
ester.zhou 已提交
11
```js
E
ester.zhou 已提交
12
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
E
ester.zhou 已提交
13 14 15 16 17 18 19 20 21 22
```

## Attributes

**System capability**: SystemCapability.MiscServices.InputMethodFramework

| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [InputMethodExtensionContext](js-apis-inputmethod-extension-context.md) | Yes| No| Context of the **InputMethodExtension**, which is inherited from **ExtensionContext**.|

E
ester.zhou 已提交
23
## InputMethodExtensionAbility.onCreate
E
ester.zhou 已提交
24

E
ester.zhou 已提交
25
onCreate(want: Want): void
E
ester.zhou 已提交
26 27 28 29 30 31 32

Called when the **InputMethodExtension** ability is started to implement initialization.

**System capability**: SystemCapability.MiscServices.InputMethodFramework

**Parameters**

E
ester.zhou 已提交
33 34 35
| Name| Type         | Mandatory| Description                            |
| ------ | ----------- | ---- | ------------------------------- |
| want   | [Want](js-apis-app-ability-want.md) | Yes  | Information related to the **InputMethodExtension** ability, including the ability name and bundle name.|
E
ester.zhou 已提交
36 37 38

**Example**

E
ester.zhou 已提交
39 40
```js
class InputMethodExt extends InputMethodExtensionAbility {
E
ester.zhou 已提交
41 42 43
  onCreate(want) {
    console.log('onCreate, want:' + want.abilityName);
  }
E
ester.zhou 已提交
44 45
}
```
E
ester.zhou 已提交
46

E
ester.zhou 已提交
47
## InputMethodExtensionAbility.onDestroy
E
ester.zhou 已提交
48

E
ester.zhou 已提交
49
onDestroy(): void
E
ester.zhou 已提交
50 51 52 53 54 55 56

Called when this **InputMethodExtension** ability is destroyed to clear resources.

**System capability**: SystemCapability.MiscServices.InputMethodFramework

**Example**

E
ester.zhou 已提交
57 58
```js
class InputMethodExt extends InputMethodExtensionAbility {
E
ester.zhou 已提交
59 60 61
  onDestroy() {
    console.log('onDestroy');
  }
E
ester.zhou 已提交
62 63
}
```