提交 534b4b73 编写于 作者: E ester.zhou

Add and update docs (12035)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 89466409
# InputMethodExtensionAbility
The **InputMethodExtensionAbility** module provides the **InputMethodExtensionAbility** and **InputMethodExtensionContext** APIs that you can implement to develop input methods and manage their lifecycles.
The **InputMethodExtensionAbility** module provides APIs for developing input methods and managing their lifecycles.
> **NOTE**
>
>
> 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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```
```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
```
......@@ -21,10 +20,9 @@ import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
| -------- | -------- | -------- | -------- | -------- |
| context | [InputMethodExtensionContext](js-apis-inputmethod-extension-context.md) | Yes| No| Context of the **InputMethodExtension**, which is inherited from **ExtensionContext**.|
## InputMethodExtensionAbility.onCreate
## InputMethodExtensionAbility.onCreate()
onCreate(want: Want): void;
onCreate(want: Want): void
Called when the **InputMethodExtension** ability is started to implement initialization.
......@@ -32,24 +30,23 @@ Called when the **InputMethodExtension** ability is started to implement initial
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to the **InputMethodExtension** ability, including the ability name and bundle name. |
| 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.|
**Example**
```js
class InputMethodExt extends InputMethodExtensionAbility {
```js
class InputMethodExt extends InputMethodExtensionAbility {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
console.log('onCreate, want:' + want.abilityName);
}
}
```
}
```
## InputMethodExtensionAbility.onDestroy()
## InputMethodExtensionAbility.onDestroy
onDestroy(): void;
onDestroy(): void
Called when this **InputMethodExtension** ability is destroyed to clear resources.
......@@ -57,10 +54,10 @@ Called when this **InputMethodExtension** ability is destroyed to clear resource
**Example**
```js
class InputMethodExt extends InputMethodExtensionAbility {
```js
class InputMethodExt extends InputMethodExtensionAbility {
onDestroy() {
console.log('onDestroy');
console.log('onDestroy');
}
}
```
}
```
......@@ -5,9 +5,8 @@ The **InputMethodExtensionContext** module, inherited from **ExtensionContext**,
You can use the APIs of this module to start, terminate, connect, and disconnect abilities.
> **NOTE**
>
> 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.
> The APIs of this module can be used only in the stage model.
>
>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
......@@ -20,112 +19,17 @@ import InputMethodExtensionContext from '@ohos.inputmethodextensioncontext';
Before using the **InputMethodExtensionContext** module, you must define a child class that inherits from **InputMethodExtensionAbility**.
```js
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
class MainAbility extends InputMethodExtensionAbility {
onCreate() {
let context = this.context;
}
}
import InputMethodExtensionAbility from '@ohos.inputmethodextensionability';
class MainAbility extends InputMethodExtensionAbility {
onCreate() {
let context = this.context;
}
}
```
## InputMethodExtensionContext.startAbility
## InputMethodExtensionContext.destroy
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
Starts an ability with the **want** parameter. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
let want = {
'bundleName': 'com.example.myapp',
'abilityName': 'MyAbility'
};
this.context.startAbility(want, (err) => {
console.log('startAbility result:' + JSON.stringify(err));
});
```
## InputMethodExtensionContext.startAbility
startAbility(want: Want, options?: StartOptions): Promise\<void>;
Starts an ability with the mandatory **want** and optional **options** parameters. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.|
| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let want = {
'bundleName': 'com.example.myapp',
'abilityName': 'MyAbility'
};
this.context.startAbility(want).then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
## InputMethodExtensionContext.startAbility
startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void
Starts an ability with the **want** and **options** parameters. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var want = {
'deviceId': '',
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility'
};
var options = {
windowMode: 0,
};
this.context.startAbility(want, options, (error) => {
console.log('error.code = ' + error.code)
})
```
## InputMethodExtensionContext.terminateSelf
terminateSelf(callback: AsyncCallback&lt;void&gt;): void;
destroy(callback: AsyncCallback\<void>): void
Terminates this ability. This API uses an asynchronous callback to return the result.
......@@ -133,21 +37,21 @@ Terminates this ability. This API uses an asynchronous callback to return the re
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
this.context.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringify(err));
```js
this.context.destroy((err) => {
console.log('destroy result:' + JSON.stringify(err));
});
```
```
## InputMethodExtensionContext.terminateSelf
## InputMethodExtensionContext.destroy
terminateSelf(): Promise&lt;void&gt;;
destroy(): Promise<void&gt;
Terminates this ability. This API uses a promise to return the result.
......@@ -155,16 +59,16 @@ Terminates this ability. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void&gt; | Promise that returns no value.|
**Example**
```js
this.context.terminateSelf().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
```js
this.context.destroy().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
# Input Method Subtype
The **inputMethodEngine** module provides APIs for managing the attributes of input method subtypes. Different attribute settings result in different subtypes.
> **NOTE**
>
>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
```
import inputMethodEngine from '@ohos.inputMethodSubtype';
```
## Attributes
**System capability**: SystemCapability.MiscServices.InputMethodFramework
| Name| Type| Readable| Writable| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| label | string | Yes| No| No| Label of the input method subtype.|
| name | string | Yes| No| Yes| Name of the input method subtype.|
| id | string | Yes| No| Yes| ID of the input method subtype.|
| mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
| locale | string | Yes| No| Yes| Locale of the input method subtype.|
| language | string | Yes| No| Yes| Language of the input method subtype.|
| icon | string | Yes| No| No| Icon of the input method subtype.|
| iconId | number | Yes| No| No| Icon ID of the input method subtype.|
| extra | object | Yes| Yes| Yes| Extra information of the input method subtype.|
# Input Method Framework Error Codes
## 12800001 Package Manager Error
**Error Message**
Package manager error.
**Description**
This error code is reported when an API of the package manager, such as **getInputMethods** and **listCurrentInputMethodSubtype**, fails to be invoked to obtain information.
**Possible Causes**
The package manager is not working correctly.
**Solution**
None
## 12800002 Input Method Engine Error
**Error Message**
Input method engine error.
**Description**
This error code is reported when an input method API fails to be invoked.
**Possible Causes**
The input method process is suspended.
**Solution**
Check whether the input method process is running properly. For example, click the input text box in an appliccation and check whether the input keyboard is displayed.
## 12800003 Input Method Client Error
**Error Message**
Input method client error.
**Description**
This error code is reported when the API for showing or hiding the keyboard fails to be invoked by a third-party application.
**Possible Causes**
The input method is disconnected from the third-party application due to a service error with the application.
**Solution**
Bind the input method to the third-party application again: Close the background process of the third-party application, start the application again, and touch an input text box. If the keyboard is displayed properly, the issue is resolved.
## 12800004 Key Event Processing Error
**Error Message**
Key event processing error.
**Description**
This error code is reported when a key event error occurs.
**Possible Causes**
An exception occurs during key event distribution, consumption, or listening.
**Solution**
None
## 12800005 Configuration Persistence Error
**Error Message**
Configuration persisting error.
**Description**
This error code is reported when the configuration fails to be saved during input method switching.
**Possible Causes**
An exception occurs with the system parameter configuration module.
**Solution**
Run the **hdc shell param get persist.sys.default_ime** command to check the default input method parameters. If the parameters are displayed, the system parameter configuration module is working properly. In this case, restart the device and try again.
## 12800006 Input Method Controller Error
**Error Message**
Input method controller error.
**Description**
This error code is reported when the input method controller fails to be obtained.
**Possible Causes**
An error occurs during invoking of the **getCotroller** API.
**Solution**
None
## 12800007 Input Method Setter Error
**Error Message**
Input method settings extension error.
**Description**
This error code is reported when an **InputMethodSetting** instance fails to be obtained.
**Possible Causes**
An error occurs during invoking of the **getSetting** API.
**Solution**
None
## 12800008 Input Method Manager Service Error
**Error Message**
Input method manager service error.
**Description**
This error code is reported when an API of the [input method framework](../apis/js-apis-inputmethod.md) fails to be invoked.
**Possible Causes**
The input method manager service fails to be obtained.
**Solution**
Run the **ps -A|grep inputmethod** command to check for the process ID of the input method service. If the process ID is found, the service is working properly.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册