Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/accessibilityservice/InputMethod#nestedclasses) \| [Ctors](https://developer.android.com/reference/android/accessibilityservice/InputMethod#pubctors) \| [Methods](https://developer.android.com/reference/android/accessibilityservice/InputMethod#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/accessibilityservice/InputMethod#inhmethods)

# InputMethod

*** ** * ** ***

` public class InputMethod `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.accessibilityservice.InputMethod |

<br />

*** ** * ** ***

This class provides input method APIs. Some public methods such as `https://developer.android.com/reference/android/accessibilityservice/InputMethod#onUpdateSelection(int,%20int,%20int,%20int,%20int,%20int)` do nothing by default and service developers should override them as needed. Developers should also override `https://developer.android.com/reference/android/accessibilityservice/AccessibilityService#onCreateInputMethod()` to return their custom InputMethod implementation. Accessibility services also need to set the `https://developer.android.com/reference/android/accessibilityservice/AccessibilityServiceInfo#FLAG_INPUT_METHOD_EDITOR` flag to use input method APIs.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/accessibilityservice/InputMethod.AccessibilityInputConnection` This class provides the allowed list of `https://developer.android.com/reference/android/view/inputmethod/InputConnection` APIs for accessibility services. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#InputMethod(android.accessibilityservice.AccessibilityService)(https://developer.android.com/reference/android/accessibilityservice/AccessibilityService service) ` Creates a new InputMethod instance for the given `service`, so that the accessibility service can control editing. |

| ### Public methods ||
|---|---|
| ` final https://developer.android.com/reference/android/accessibilityservice/InputMethod.AccessibilityInputConnection` | ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#getCurrentInputConnection()() ` Retrieve the currently active InputConnection that is bound to the input method, or null if there is none. |
| ` final https://developer.android.com/reference/android/view/inputmethod/EditorInfo` | ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#getCurrentInputEditorInfo()() ` Get the EditorInfo which describes several attributes of a text editing object that an accessibility service is communicating with (typically an EditText). |
| ` final boolean` | ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#getCurrentInputStarted()() ` Whether the input has started. |
| ` void` | ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#onFinishInput()() ` Called to inform the accessibility service that text input has finished in the last editor. |
| ` void` | ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#onStartInput(android.view.inputmethod.EditorInfo,%20boolean)(https://developer.android.com/reference/android/view/inputmethod/EditorInfo attribute, boolean restarting) ` Called to inform the accessibility service that text input has started in an editor. |
| ` void` | ` https://developer.android.com/reference/android/accessibilityservice/InputMethod#onUpdateSelection(int,%20int,%20int,%20int,%20int,%20int)(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) ` Called when the application has reported a new selection region of the text. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### InputMethod

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

```
public InputMethod (AccessibilityService service)
```

Creates a new InputMethod instance for the given `service`, so that the accessibility service can control editing.

<br />

| Parameters ||
|---|---|
| `service` | `AccessibilityService`: This value cannot be `null`. <br /> |

## Public methods

### getCurrentInputConnection

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

```
public final InputMethod.AccessibilityInputConnection getCurrentInputConnection ()
```

Retrieve the currently active InputConnection that is bound to the input method, or null if there is none.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/accessibilityservice/InputMethod.AccessibilityInputConnection` | <br /> |

### getCurrentInputEditorInfo

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

```
public final EditorInfo getCurrentInputEditorInfo ()
```

Get the EditorInfo which describes several attributes of a text editing object that an accessibility service is communicating with (typically an EditText).

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/EditorInfo` | This value may be `null`. <br /> |

### getCurrentInputStarted

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

```
public final boolean getCurrentInputStarted ()
```

Whether the input has started.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### onFinishInput

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

```
public void onFinishInput ()
```

Called to inform the accessibility service that text input has finished in the last editor. At this point there may be a call to `https://developer.android.com/reference/android/accessibilityservice/InputMethod#onStartInput(android.view.inputmethod.EditorInfo,%20boolean)` to perform input in a new editor, or the accessibility service may be left idle. This method is *not* called when input restarts in the same editor.

The default implementation uses the InputConnection to clear any active composing text; you can override this (not calling the base class implementation) to perform whatever behavior you would like.

<br />

### onStartInput

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

```
public void onStartInput (EditorInfo attribute, 
                boolean restarting)
```

Called to inform the accessibility service that text input has started in an editor. You should use this callback to initialize the state of your input to match the state of the editor given to it.

<br />

| Parameters ||
|---|---|
| `attribute` | `EditorInfo`: The attributes of the editor that input is starting in. This value cannot be `null`. <br /> |
| `restarting` | `boolean`: Set to true if input is restarting in the same editor such as because the application has changed the text in the editor. Otherwise will be false, indicating this is a new session with the editor. <br /> |

### onUpdateSelection

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

```
public void onUpdateSelection (int oldSelStart, 
                int oldSelEnd, 
                int newSelStart, 
                int newSelEnd, 
                int candidatesStart, 
                int candidatesEnd)
```

Called when the application has reported a new selection region of the text. This is called whether or not the accessibility service has requested extracted text updates, although if so it will not receive this call if the extracted text has changed as well.

Be careful about changing the text in reaction to this call with methods such as setComposingText, commitText or deleteSurroundingText. If the cursor moves as a result, this method will be called again, which may result in an infinite loop.

<br />

| Parameters ||
|---|---|
| `oldSelStart` | `int` <br /> |
| `oldSelEnd` | `int` <br /> |
| `newSelStart` | `int` <br /> |
| `newSelEnd` | `int` <br /> |
| `candidatesStart` | `int` <br /> |
| `candidatesEnd` | `int` <br /> |