# AbstractInputMethodService.AbstractInputMethodSessionImpl

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# AbstractInputMethodSessionImpl

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl "View this page in Java")  

```
abstract class AbstractInputMethodSessionImpl : InputMethodSession
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                                                               ||
| ↳ | [android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodSessionImpl](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#) |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [InputMethodService.InputMethodSessionImpl](https://developer.android.com/reference/kotlin/android/inputmethodservice/InputMethodService.InputMethodSessionImpl) |------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [InputMethodService.InputMethodSessionImpl](https://developer.android.com/reference/kotlin/android/inputmethodservice/InputMethodService.InputMethodSessionImpl) | Concrete implementation of[AbstractInputMethodService.AbstractInputMethodSessionImpl](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#)that provides all of the standard behavior for an input method session. | |

Base class for derived classes to implement their[InputMethodSession](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#)interface. This takes care of basic maintenance of the session, but most behavior must be implemented in a derived class.

## Summary

|                                                                                                 Public constructors                                                                                                  ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [AbstractInputMethodSessionImpl](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#AbstractInputMethodSessionImpl())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                                                              Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
|----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [dispatchGenericMotionEvent](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#dispatchGenericMotionEvent(kotlin.Int,%20android.view.MotionEvent,%20android.view.inputmethod.InputMethodSession.EventCallback))`(`seq:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!`, `callback:` `[InputMethodSession.EventCallback](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.EventCallback.html#)!`)` Take care of dispatching incoming generic motion events to the appropriate callbacks on the service, and tell the client when this is done. |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [dispatchKeyEvent](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#dispatchKeyEvent(kotlin.Int,%20android.view.KeyEvent,%20android.view.inputmethod.InputMethodSession.EventCallback))`(`seq:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!`, `callback:` `[InputMethodSession.EventCallback](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.EventCallback.html#)!`)` Take care of dispatching incoming key events to the appropriate callbacks on the service, and tell the client when this is done.                                         |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [dispatchTrackballEvent](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#dispatchTrackballEvent(kotlin.Int,%20android.view.MotionEvent,%20android.view.inputmethod.InputMethodSession.EventCallback))`(`seq:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!`, `callback:` `[InputMethodSession.EventCallback](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.EventCallback.html#)!`)` Take care of dispatching incoming trackball events to the appropriate callbacks on the service, and tell the client when this is done.              |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isEnabled](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#isEnabled())`()` Check whether this session has been enabled by the system.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isRevoked](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#isRevoked())`()` Check whether this session has been revoked by the system.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onShouldVerifyKeyEvent](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#onShouldVerifyKeyEvent(android.view.KeyEvent))`(`event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)`)` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [revokeSelf](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#revokeSelf())`()` Revoke the session from the client.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [setEnabled](https://developer.android.com/reference/kotlin/android/inputmethodservice/AbstractInputMethodService.AbstractInputMethodSessionImpl#setEnabled(kotlin.Boolean))`(`enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Change the enabled state of the session.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

| Inherited functions ||
|---|---|
| From class[InputMethodSession](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#) |------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [appPrivateCommand](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#appPrivateCommand(kotlin.String,%20android.os.Bundle))`(`action:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `data:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` <br /> Process a private command sent from the application to the input method. This can be used to provide domain-specific features that are only known between certain input methods and their clients. <br />                                                                                                                                                                                                                                                                                                                              | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [displayCompletions](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#displayCompletions(kotlin.Array))`(`completions:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[CompletionInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CompletionInfo.html#)!>!`)` <br /> Called by a text editor that performs auto completion, to tell the input method about the completions it has available. This can be used by the input method to display them to the user to select the text to be inserted. <br />                                                                                                                                                                                                                                                                                                  | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [finishInput](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#finishInput())`()` <br /> This method is called when the application would like to stop receiving text input. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [toggleSoftInput](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#toggleSoftInput(kotlin.Int,%20kotlin.Int))`(`showFlags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `hideFlags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Toggle the soft input window. Applications can toggle the state of the soft input window. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [updateCursor](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#updateCursor(android.graphics.Rect))`(`newCursor:` `[Rect](https://developer.android.com/reference/kotlin/android/graphics/Rect.html#)!`)` <br /> This method is called when cursor location of the target input field has changed within its window. This is not normally called, but will only be reported if requested by the input method. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [updateCursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#updateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo))`(`cursorAnchorInfo:` `[CursorAnchorInfo](https://developer.android.com/reference/kotlin/android/view/inputmethod/CursorAnchorInfo.html#)!`)` <br /> This method is called when the cursor and/or the character position relevant to text input is changed on the screen. This is not called by default. It will only be reported if requested by the input method. <br />                                                                                                                                                                                                                                                                                                                                                  | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [updateExtractedText](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#updateExtractedText(kotlin.Int,%20android.view.inputmethod.ExtractedText))`(`token:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `text:` `[ExtractedText](https://developer.android.com/reference/kotlin/android/view/inputmethod/ExtractedText.html#)!`)` <br /> Called by a text editor to report its new extracted text when its contents change. This will only be called if the input method calls[InputConnection.getExtractedText()](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputConnection.html#getExtractedText(android.view.inputmethod.ExtractedTextRequest,%20kotlin.Int))with the option to report updates. <br />                                                                                               | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [updateSelection](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#updateSelection(kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`oldSelStart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `oldSelEnd:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `newSelStart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `newSelEnd:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `candidatesStart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `candidatesEnd:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> This method is called when the selection or cursor in the current target input field has changed. <br /> | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [viewClicked](https://developer.android.com/reference/kotlin/android/view/inputmethod/InputMethodSession.html#viewClicked(kotlin.Boolean))`(`focusChanged:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` <br /> This method is called when the user tapped a text view. IMEs can't rely on this method being called because this was not part of the original IME protocol, so applications with custom text editing written before this method appeared will not call to inform the IME of this interaction. <br />                                                                                                                                                                                                                                                                                                                                                         | ||

## Public constructors

### AbstractInputMethodSessionImpl

```
AbstractInputMethodSessionImpl()
```

## Public methods

### dispatchGenericMotionEvent

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun dispatchGenericMotionEvent(
    seq: Int, 
    event: MotionEvent!, 
    callback: InputMethodSession.EventCallback!
): Unit
```

Take care of dispatching incoming generic motion events to the appropriate callbacks on the service, and tell the client when this is done.

|                                                        Parameters                                                        ||
|---------|-----------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!:The motion event. |

|                                                               Return                                                               ||
|------------------------------------------------------------------------------|------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | Whether the input method wants to handle this event. |

### dispatchKeyEvent

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun dispatchKeyEvent(
    seq: Int, 
    event: KeyEvent!, 
    callback: InputMethodSession.EventCallback!
): Unit
```

Take care of dispatching incoming key events to the appropriate callbacks on the service, and tell the client when this is done.

|                                                   Parameters                                                    ||
|---------|--------------------------------------------------------------------------------------------------------|
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!:The key event. |

|                                                               Return                                                               ||
|------------------------------------------------------------------------------|------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | Whether the input method wants to handle this event. |

### dispatchTrackballEvent

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun dispatchTrackballEvent(
    seq: Int, 
    event: MotionEvent!, 
    callback: InputMethodSession.EventCallback!
): Unit
```

Take care of dispatching incoming trackball events to the appropriate callbacks on the service, and tell the client when this is done.

|                                                        Parameters                                                        ||
|---------|-----------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!:The motion event. |

|                                                               Return                                                               ||
|------------------------------------------------------------------------------|------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | Whether the input method wants to handle this event. |

### isEnabled

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isEnabled(): Boolean
```

Check whether this session has been enabled by the system. If not enabled, you should not execute any calls on to it.  

### isRevoked

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isRevoked(): Boolean
```

Check whether this session has been revoked by the system. Revoked session is also always disabled, so there is generally no need to explicitly check for this.  

### onShouldVerifyKeyEvent

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onShouldVerifyKeyEvent(event: KeyEvent): Boolean
```

|                                                         Parameters                                                          ||
|---------|--------------------------------------------------------------------------------------------------------------------|
| `event` | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#):This value cannot be`null`. |

### revokeSelf

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun revokeSelf(): Unit
```

Revoke the session from the client. This disabled the session, and prevents it from ever being enabled again.  

### setEnabled

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setEnabled(enabled: Boolean): Unit
```

Change the enabled state of the session. This only works if the session has not been revoked.