harmony 鸿蒙@ohos.InputMethodExtensionContext (InputMethodExtensionContext)

  • 2022-10-28
  • 浏览 (639)

@ohos.InputMethodExtensionContext (InputMethodExtensionContext)

The InputMethodExtensionContext module, inherited from ExtensionContext, provides context for InputMethodExtension abilities. 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.

Modules to Import

import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';

Usage

Before using the InputMethodExtensionContext module, you must define a child class that inherits from InputMethodExtensionAbility.

import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
import Want from '@ohos.app.ability.Want';
class InputMethodExtnAbility extends InputMethodExtensionAbility {
  onCreate(want: Want): void {
    let context = this.context;
  }
}

InputMethodExtensionContext.destroy

destroy(callback: AsyncCallback<void>): void

Destroys this input method. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.MiscServices.InputMethodFramework

Parameters

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

this.context.destroy((err: BusinessError) => {
  if(err) {
    console.log('Failed to destroy context.');
    return;
  }
  console.log('Succeeded in destroying context.');
});

InputMethodExtensionContext.destroy

destroy(): Promise<void>;

Destroys this input method. This API uses a promise to return the result.

System capability: SystemCapability.MiscServices.InputMethodFramework

Return value

Type Description
Promise<void> Promise that returns no value.

Example

this.context.destroy().then(() => {
  console.log('Succeed in destroying context.');
}).catch((err: BusinessError)=>{
  console.log('Failed to destroy context.');
});

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

0  赞