ILifecycle, Contextpublic abstract class InputMethodAbility extends Ability
You should extend this class to implement the input method ability. Processes such as enabling and hiding the input method are encapsulated in this class. This allows you to complete the development only by implementing specific APIs, without extra efforts on internal processes.
InputMethodAbility inherits from the Ability class. The lifecycle (such as startup and connection)
of the input method ability is the same as that of a generic ability. In addition, lifecycle callbacks related to the
input method service are supported, for example, callbacks for creating the keyboard component container
(onCreateKeyboardContainer()) and for displaying the keyboard window (onShowKeyboard()). As an ability,
an InputMethodAbility object only can be connected to specific system services supported by the framework.
Applications developed based on the input method ability is able to adjust the input method window size (via
KeyboardController), and perform many operations such as text input and deletion in the client application
(via TextInputClient).
SystemCapability.Miscservices#INPUTMETHODAbility.LayoutParamsHelper, Ability.WindowAttributeHelperFORM_INVISIBLE, FORM_VISIBLECONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESOUCE_ONLY, CONTEXT_RESTRICTED, MODE_APPEND, MODE_PRIVATE| 构造器 | 说明 |
|---|---|
InputMethodAbility() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
protected void |
onBeginInput(KeyboardController kbController,
TextInputClient textInputClient) |
Called to pass a
KeyboardController and a TextInputClient object from the framework to the input
method when the input starts. |
protected void |
onCommand(Intent intent,
boolean restart,
int startId) |
Called back when Service is started.
|
void |
onConfigurationUpdated(Configuration configuration) |
Called when the system configuration is updated.
|
protected IRemoteObject |
onConnect(Intent intent) |
Called back when a Service ability is first connected to an ability.
|
protected ComponentContainer |
onCreateKeyboardContainer() |
Called when an input method keyboard window is created.
|
protected abstract KeyboardDelegate |
onCreateKeyboardInterface() |
Called when the input method ability starts.
|
protected void |
onDisconnect(Intent intent) |
Called back when all abilities connected to a Service ability are disconnected.
|
protected void |
onEndInput() |
Called when the input stops.
|
protected void |
onHideKeyboard() |
Called when the input method keyboard is hidden.
|
protected void |
onScreenOrientationChanged(int direction) |
Called when the display direction of the screen changes.
|
protected void |
onShowKeyboard() |
Called when the input method keyboard is displayed.
|
protected void |
onStart(Intent intent) |
Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of
an ability).
|
protected void |
onStop() |
Called back before an ability is destroyed.
|
addActionRoute, batchInsert, call, cancelBackgroundRunning, connectAbility, continueAbility, continueAbility, continueAbilityReversibly, continueAbilityReversibly, createPipeFile, delete, denormalizeUri, disconnectAbility, dispatchAccessibilityEventInfo, executeBatch, executeOperation, findComponentById, getAbilityName, getAbilityPackage, getAdmissionTransitionConcurEnabled, getAdmissionTransitionObject, getAVController, getBackTransitionConcurEnabled, getBackTransitionObject, getContinuationRegisterManager, getContinuationState, getCurrentFocus, getFileTypes, getIntent, getLayoutParams, getLifecycle, getOriginalDeviceId, getQuitTransitionObject, getReadmissionTransitionObject, getSharedItemAdmissionTransitionObject, getSharedItemBackTransitionObject, getSharedItemQuitTransitionObject, getSharedItemReadmissionTransitionObject, getState, getType, getVolumeTypeAdjustedByKey, getWindow, hasWindowFocus, insert, isTemporary, isTerminating, keepBackgroundRunning, normalizeUri, onAbilityResult, onAcquireFormState, onActive, onBackground, onBackPressed, onCastTempForm, onCommand, onCreateForm, onCreateForm, onDeleteForm, onDeleteForm, onEventDispatch, onEventNotify, onForeground, onHotkeyTriggered, onInactive, onInitialized, onKeyDown, onKeyPressAndHold, onKeyUp, onLeaveForeground, onMemoryLevel, onMissionDeleted, onNewDescription, onNewIntent, onOrientationChanged, onPostActive, onPostStart, onReconnect, onRequestPermissionsFromUserResult, onRestoreAbilityState, onSaveAbilityState, onSetCaller, onStoreDataWhenConfigChange, onTopActiveAbilityChanged, onTouchEvent, onTriggerFormEvent, onTriggerFormEvent, onUnloadForm, onUpdateForm, onUpdateForm, onWindowFocusChanged, openFile, openRawFile, parsePredictionArgsReference, parseValuesBucketReference, postTask, query, reload, reverseContinueAbility, setAbilitySliceAnimator, setAdmissionTransitionConcurEnabled, setAdmissionTransitionObject, setAVController, setBackTransitionConcurEnabled, setBackTransitionObject, setFormNextRefreshTime, setIntent, setIsAmbientMode, setLayoutParams, setMainRoute, setQuitTransitionObject, setReadmissionTransitionObject, setResult, setSharedItemAdmissionTransitionObject, setSharedItemBackTransitionObject, setSharedItemQuitTransitionObject, setSharedItemReadmissionTransitionObject, setSwipeToDismiss, setUIContent, setUIContent, setVolumeTypeAdjustedByKey, setWindowBackgroundColor, shutdown, startAbility, startAbility, startAbility, startAbility, startAbilityForResult, startAbilityForResult, startAssistAbility, stopAbility, stopAssistAbility, supportHighPerformanceUI, terminateAbility, update, updateForm, updateForm, updateForm, updateFormattachBaseContext, canRequestPermission, compelVerifyCallerPermission, compelVerifyCallerUriPermission, compelVerifyPermission, compelVerifyPermission, compelVerifyUriPermission, compelVerifyUriPermission, compelVerifyUriPermission, createBundleContext, createParallelTaskDispatcher, createSerialTaskDispatcher, deleteFile, displayUnlockMissionMessage, getAbilityInfo, getAbilityManager, getAbilityPackageContext, getApplicationContext, getApplicationInfo, getAppType, getBundleCodePath, getBundleManager, getBundleName, getBundleResourcePath, getCacheDir, getCaller, getCallingAbility, getCallingBundle, getClassloader, getCodeCacheDir, getColor, getColorMode, getContext, getDatabaseDir, getDataDir, getDir, getDisplayOrientation, getDistributedDir, getElementName, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getGlobalTaskDispatcher, getHapModuleInfo, getIntArray, getLastStoredDataWhenConfigChanged, getLocalClassName, getMainTaskDispatcher, getNoBackupFilesDir, getPattern, getPreferencesDir, getProcessInfo, getProcessName, getResourceManager, getResourceManager, getString, getString, getStringArray, getTheme, getThemeId, getUITaskDispatcher, init, isCredentialEncryptedStorage, isDeviceEncryptedStorage, isUpdatingConfigurations, lockMission, printDrawnCompleted, requestPermissionsFromUser, restart, setColorMode, setDisplayOrientation, setPattern, setShowOnLockScreen, setTheme, setTransitionAnimation, setWakeUpScreen, startAbilities, startAbility, startAbility, startAbility, switchToCredentialEncryptedStorageContext, switchToDeviceEncryptedStorageContext, terminateAbility, terminateAbilityResult, unlockMission, verifyCallingOrSelfPermission, verifyCallingPermission, verifyPermission, verifySelfPermissionprotected abstract KeyboardDelegate onCreateKeyboardInterface()
KeyboardDelegate object for the
input method keyboard.
You can implement the delegate interface in which many callbacks are defined for different service processes.
For example, KeyboardDelegate#onTextChanged is called when the application enters full-screen mode.
protected void onStart(Intent intent)
AbilityMost initialization operations should be performed by calling this method. For example, you can use the
current method to call Ability.setMainRoute(java.lang.String) and
Ability.addActionRoute(java.lang.String,java.lang.String) to set the main router and action router for a Page ability.
protected IRemoteObject onConnect(Intent intent)
AbilityThis method is called only on Service abilities. You can override the method to return the proxy of a Service ability.
protected void onDisconnect(Intent intent)
AbilityThis method is called only on Service abilities. You can override the method to clear resources of the proxy of a Service ability.
onDisconnect 在类中 Abilityintent - Indicates disconnection information about the Service ability.protected void onStop()
AbilityThis method indicates the end of the ability lifecycle. It can be executed after the ability calls the
Ability.terminateAbility() method or the last ability slice of the ability calls the
AbilitySlice#terminate() method. Generally, this method is used to clear resources.
protected void onCommand(Intent intent, boolean restart, int startId)
AbilityThis method can be called only by Service. You can use the Ability.startAbility(ohos.aafwk.content.Intent) method to start
Service. Then the system calls back the current method to use the transferred intent parameter to
execute its own logic.
onCommand 在类中 Abilityintent - Indicates the intent of Service to start.restart - Indicates the startup mode. The value true indicates that Service is restarted after being
destroyed, and the value false indicates a normal startup.startId - Indicates the number of times the Service ability has been started. The startId is
incremented by 1 every time the ability is started. For example, if the ability has been started
for six times, the value of startId is 6.public void onConfigurationUpdated(Configuration configuration)
AbilityonConfigurationUpdated 在类中 Abilityconfiguration - Indicates the updated configuration information.protected ComponentContainer onCreateKeyboardContainer()
You can implement this callback to pass your component container to the framework. The framework assigns the container to the keyboard window for layout.
protected void onBeginInput(KeyboardController kbController, TextInputClient textInputClient)
KeyboardController and a TextInputClient object from the framework to the input
method when the input starts.
The framework passes the KeyboardController and TextInputClient objects to the input method.
You need to save the two objects for keyboard control and communications between the input method and the client.
The default implementation does nothing. If you need to change the input method mode (for example, to the
full-screen mode), call KeyboardController#setDisplayMode in this method and set the layout.
kbController - Indicates the KeyboardController object for keyboard-related operations, including
switching and hiding.textInputClient - Indicates the TextInputClient object, which can be used by the input method to
insert or delete text.protected void onEndInput()
You can override this method to define operations when the input stops, for example, to release an ongoing process on the client. The default implementation does nothing.
protected void onShowKeyboard()
You can override this method to define operations after the keyboard is displayed. The default implementation does nothing.
protected void onScreenOrientationChanged(int direction)
You can override this callback to define operations upon a display direction change, for example, to enter the full-screen mode. The default implementation does nothing.
direction - Indicates the current layout direction. ohos.global.Configuration#DIRECTION_VERTICAL
indicates that the screen is displayed vertically. ohos.global.Configuration#DIRECTION_HORIZONTAL
indicates that the screen is displayed horizontally.protected void onHideKeyboard()
You can override this method to define operations after the keyboard is hidden. The default implementation does nothing.