Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Constants](https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#inhconstants) \| [Ctors](https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#pubctors) \| [Methods](https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#inhmethods)

# BaseInputConnection

*** ** * ** ***


`
public


class
BaseInputConnection
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/view/inputmethod/InputConnection


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.inputmethod.BaseInputConnection |

<br />

*** ** * ** ***

Base class for implementors of the InputConnection interface, taking care
of most of the common behavior for providing a connection to an Editable.
Implementors of this class will want to be sure to implement
`https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getEditable()` to provide access to their own editable object, and
to refer to the documentation in `https://developer.android.com/reference/android/view/inputmethod/InputConnection`.

## Summary

### Inherited constants

From interface `https://developer.android.com/reference/android/view/inputmethod/InputConnection` `int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_CHARACTER_BOUNDS`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`
with new character bounds `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#getCharacterBounds(int)` whenever
cursor/anchor position is changed.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_EDITOR_BOUNDS`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`
with new `https://developer.android.com/reference/android/view/inputmethod/EditorBoundsInfo` whenever cursor/anchor position is changed.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_INSERTION_MARKER`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`
with new Insertion marker info `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#getInsertionMarkerFlags()`,
`https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#getInsertionMarkerBaseline()`, etc whenever cursor/anchor position is
changed.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_TEXT_APPEARANCE`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`
with new text appearance info `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#getTextAppearanceInfo()`}
whenever cursor/anchor position is changed.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_VISIBLE_LINE_BOUNDS`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`
with new visible line bounds `https://developer.android.com/reference/android/view/inputmethod/CursorAnchorInfo#getVisibleLineBounds()` whenever
cursor/anchor position is changed, the editor or its parent is scrolled or the line bounds
changed due to text updates.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_IMMEDIATE`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)` at
once, as soon as possible, regardless of cursor/anchor position changes.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_MONITOR`

The editor is requested to call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`
whenever cursor/anchor position is changed.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_EXTRACTED_TEXT_MONITOR`

Flag for use with `https://developer.android.com/reference/android/view/inputmethod/InputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest,%20int)` to indicate you
would like to receive updates when the extracted text changes.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_TEXT_WITH_STYLES`

Flag for use with `https://developer.android.com/reference/android/view/inputmethod/InputConnection#getTextAfterCursor(int,%20int)`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#getTextBeforeCursor(int,%20int)` and
`https://developer.android.com/reference/android/view/inputmethod/InputConnection#getSurroundingText(int,%20int,%20int)` to have style information returned along with the text.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#HANDWRITING_GESTURE_RESULT_CANCELLED`

Result for `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)` when
`https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` was cancelled.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#HANDWRITING_GESTURE_RESULT_FAILED`

Result for `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)` when
`https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` failed and there was no applicable
`https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#getFallbackText()` or it couldn't
be applied for any other reason.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#HANDWRITING_GESTURE_RESULT_FALLBACK`

Result for `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)` when
`https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` failed but `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#getFallbackText()` was
committed.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#HANDWRITING_GESTURE_RESULT_SUCCESS`

Result for `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)` when
`https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` is successfully executed on text.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#HANDWRITING_GESTURE_RESULT_UNKNOWN`

Result for `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)` when
editor didn't provide any result.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#HANDWRITING_GESTURE_RESULT_UNSUPPORTED`

Result for `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)` when
`https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` is unsupported by the current editor.


`int` `https://developer.android.com/reference/android/view/inputmethod/InputConnection#INPUT_CONTENT_GRANT_READ_URI_PERMISSION`

When this flag is used, the editor will be able to request read access to the content URI
contained in the `https://developer.android.com/reference/android/view/inputmethod/InputContentInfo` object.


| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#BaseInputConnection(android.view.View,%20boolean)(https://developer.android.com/reference/android/view/View targetView, boolean fullEditor) ` |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#beginBatchEdit()() ` Default implementation does nothing. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#clearMetaKeyStates(int)(int states) ` Default implementation uses `https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(long,%20int)` to clear the state. |
| ` void` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#closeConnection()() ` Default implementation calls `https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#finishComposingText()` and `setImeConsumesInput(false)`. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#commitCompletion(android.view.inputmethod.CompletionInfo)(https://developer.android.com/reference/android/view/inputmethod/CompletionInfo text) ` Default implementation does nothing and returns false. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#commitContent(android.view.inputmethod.InputContentInfo,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/view/inputmethod/InputContentInfo inputContentInfo, int flags, https://developer.android.com/reference/android/os/Bundle opts) ` Default implementation which invokes `https://developer.android.com/reference/android/view/View#performReceiveContent(android.view.ContentInfo)` on the target view if the view `https://developer.android.com/reference/android/view/View#getReceiveContentMimeTypes()` content insertion; otherwise returns false without any side effects. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#commitCorrection(android.view.inputmethod.CorrectionInfo)(https://developer.android.com/reference/android/view/inputmethod/CorrectionInfo correctionInfo) ` Default implementation does nothing and returns false. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#commitText(java.lang.CharSequence,%20int)(https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition) ` Default implementation replaces any existing composing text with the given text. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#deleteSurroundingText(int,%20int)(int beforeLength, int afterLength) ` The default implementation performs the deletion around the current selection position of the editable text. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#deleteSurroundingTextInCodePoints(int,%20int)(int beforeLength, int afterLength) ` The default implementation performs the deletion around the current selection position of the editable text. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#endBatchEdit()() ` Default implementation does nothing. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#finishComposingText()() ` The default implementation removes the composing state from the current editable text. |
| ` static int` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getComposingSpanEnd(android.text.Spannable)(https://developer.android.com/reference/android/text/Spannable text) ` Return the end of the range of composing text, or -1 if there's no composing text. |
| ` static int` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getComposingSpanStart(android.text.Spannable)(https://developer.android.com/reference/android/text/Spannable text) ` Return the beginning of the range of composing text, or -1 if there's no composing text. |
| ` int` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getCursorCapsMode(int)(int reqModes) ` The default implementation uses TextUtils.getCapsMode to get the cursor caps mode for the current selection position in the editable text, unless in fallback mode in which case 0 is always returned. |
| ` https://developer.android.com/reference/android/text/Editable` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getEditable()() ` Return the target of edit operations. |
| ` https://developer.android.com/reference/android/view/inputmethod/ExtractedText` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest,%20int)(https://developer.android.com/reference/android/view/inputmethod/ExtractedTextRequest request, int flags) ` The default implementation always returns null. |
| ` https://developer.android.com/reference/android/os/Handler` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getHandler()() ` Called by the system to enable application developers to specify a dedicated thread on which `https://developer.android.com/reference/android/view/inputmethod/InputConnection` methods are called back. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getSelectedText(int)(int flags) ` The default implementation returns the text currently selected, or null if none is selected. |
| ` https://developer.android.com/reference/android/view/inputmethod/SurroundingText` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getSurroundingText(int,%20int,%20int)(int beforeLength, int afterLength, int flags) ` The default implementation returns the given amount of text around the current cursor position in the buffer. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getTextAfterCursor(int,%20int)(int length, int flags) ` The default implementation returns the given amount of text from the current cursor position in the buffer. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#getTextBeforeCursor(int,%20int)(int length, int flags) ` The default implementation returns the given amount of text from the current cursor position in the buffer. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#performContextMenuAction(int)(int id) ` The default implementation does nothing. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#performEditorAction(int)(int actionCode) ` The default implementation turns this into the enter key. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#performPrivateCommand(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String action, https://developer.android.com/reference/android/os/Bundle data) ` The default implementation does nothing. |
| ` static final void` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#removeComposingSpans(android.text.Spannable)(https://developer.android.com/reference/android/text/Spannable text) ` Removes the composing spans from the given text if any. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#replaceText(int,%20int,%20java.lang.CharSequence,%20int,%20android.view.inputmethod.TextAttribute)(int start, int end, https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition, https://developer.android.com/reference/android/view/inputmethod/TextAttribute textAttribute) ` Replace the specific range in the editor with suggested text. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#reportFullscreenMode(boolean)(boolean enabled) ` Updates InputMethodManager with the current fullscreen mode. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#requestCursorUpdates(int)(int cursorUpdateMode) ` The default implementation does nothing. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#sendKeyEvent(android.view.KeyEvent)(https://developer.android.com/reference/android/view/KeyEvent event) ` Provides standard implementation for sending a key event to the window attached to the input connection's view. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#setComposingRegion(int,%20int)(int start, int end) ` Mark a certain region of text as composing text. |
| ` static void` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#setComposingSpans(android.text.Spannable)(https://developer.android.com/reference/android/text/Spannable text) ` Removes the composing spans from the given text if any. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#setComposingText(java.lang.CharSequence,%20int)(https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition) ` The default implementation places the given text into the editable, replacing any existing composing text. |
| ` boolean` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#setSelection(int,%20int)(int start, int end) ` The default implementation changes the selection position in the current editable text. |
| ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` | ` https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#takeSnapshot()() ` Default implementation that constructs `https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` with information extracted from `https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection`. |

### 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*.


From interface `

https://developer.android.com/reference/android/view/inputmethod/InputConnection

` `
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#beginBatchEdit()()
`

Tell the editor that you are starting a batch of editor
operations.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#clearMetaKeyStates(int)(int states)
`

Clear the given meta key pressed states in the given input
connection.


`
abstract


void` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#closeConnection()()
`

Called by the system up to only once to notify that the system is about to invalidate
connection between the input method and the application.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitCompletion(android.view.inputmethod.CompletionInfo)(https://developer.android.com/reference/android/view/inputmethod/CompletionInfo text)
`

Commit a completion the user has selected from the possible ones
previously reported to `https://developer.android.com/reference/android/view/inputmethod/InputMethodSession#displayCompletions(android.view.inputmethod.CompletionInfo[])` or
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#displayCompletions(android.view.View,%20android.view.inputmethod.CompletionInfo[])`.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitContent(android.view.inputmethod.InputContentInfo,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/view/inputmethod/InputContentInfo inputContentInfo, int flags, https://developer.android.com/reference/android/os/Bundle opts)
`

Called by the input method to commit content such as a PNG image to the editor.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitCorrection(android.view.inputmethod.CorrectionInfo)(https://developer.android.com/reference/android/view/inputmethod/CorrectionInfo correctionInfo)
`

Commit a correction automatically performed on the raw user's input.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitText(java.lang.CharSequence,%20int,%20android.view.inputmethod.TextAttribute)(https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition, https://developer.android.com/reference/android/view/inputmethod/TextAttribute textAttribute)
`

The variant of `https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitText(java.lang.CharSequence,%20int)`.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitText(java.lang.CharSequence,%20int)(https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition)
`

Commit text to the text box and set the new cursor position.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#deleteSurroundingText(int,%20int)(int beforeLength, int afterLength)
`

Delete <var translate="no">beforeLength</var> characters of text before the
current cursor position, and delete <var translate="no">afterLength</var>
characters of text after the current cursor position, excluding
the selection.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#deleteSurroundingTextInCodePoints(int,%20int)(int beforeLength, int afterLength)
`

A variant of `https://developer.android.com/reference/android/view/inputmethod/InputConnection#deleteSurroundingText(int,%20int)`.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#endBatchEdit()()
`

Tell the editor that you are done with a batch edit previously initiated with
`https://developer.android.com/reference/android/view/inputmethod/InputConnection#beginBatchEdit()`.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#finishComposingText()()
`

Have the text editor finish whatever composing text is
currently active.


`
abstract


int` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getCursorCapsMode(int)(int reqModes)
`

Retrieve the current capitalization mode in effect at the
current cursor position in the text.


`
abstract


https://developer.android.com/reference/android/view/inputmethod/ExtractedText` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest,%20int)(https://developer.android.com/reference/android/view/inputmethod/ExtractedTextRequest request, int flags)
`

Retrieve the current text in the input connection's editor, and
monitor for any changes to it.


`
abstract


https://developer.android.com/reference/android/os/Handler` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getHandler()()
`

Called by the system to enable application developers to specify a dedicated thread on which
`https://developer.android.com/reference/android/view/inputmethod/InputConnection` methods are called back.


`
abstract


https://developer.android.com/reference/java/lang/CharSequence` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getSelectedText(int)(int flags)
`

Gets the selected text, if any.


`

default


https://developer.android.com/reference/android/view/inputmethod/SurroundingText` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getSurroundingText(int,%20int,%20int)(int beforeLength, int afterLength, int flags)
`

Gets the surrounding text around the current cursor, with <var translate="no">beforeLength</var> characters
of text before the cursor (start of the selection), <var translate="no">afterLength</var> characters of text
after the cursor (end of the selection), and all of the selected text.


`
abstract


https://developer.android.com/reference/java/lang/CharSequence` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getTextAfterCursor(int,%20int)(int n, int flags)
`

Get <var translate="no">n</var> characters of text after the current cursor
position.


`
abstract


https://developer.android.com/reference/java/lang/CharSequence` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#getTextBeforeCursor(int,%20int)(int n, int flags)
`

Get <var translate="no">n</var> characters of text before the current cursor
position.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#performContextMenuAction(int)(int id)
`

Perform a context menu action on the field.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#performEditorAction(int)(int editorAction)
`

Have the editor perform an action it has said it can do.


`

default


void` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)(https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture gesture, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/IntConsumer consumer)
`

Perform a handwriting gesture on text.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#performPrivateCommand(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String action, https://developer.android.com/reference/android/os/Bundle data)
`

API to send private commands from an input method to its
connected editor.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#performSpellCheck()()
`

Have the editor perform spell checking for the full content.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#previewHandwritingGesture(android.view.inputmethod.PreviewableHandwritingGesture,%20android.os.CancellationSignal)(https://developer.android.com/reference/android/view/inputmethod/PreviewableHandwritingGesture gesture, https://developer.android.com/reference/android/os/CancellationSignal cancellationSignal)
`

Preview a handwriting gesture on text.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#replaceText(int,%20int,%20java.lang.CharSequence,%20int,%20android.view.inputmethod.TextAttribute)(int start, int end, https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition, https://developer.android.com/reference/android/view/inputmethod/TextAttribute textAttribute)
`

Replace the specific range in the editor with suggested text.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#reportFullscreenMode(boolean)(boolean enabled)
`

Called back when the connected IME switches between fullscreen and normal modes.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#requestCursorUpdates(int,%20int)(int cursorUpdateMode, int cursorUpdateFilter)
`

Called by the input method to ask the editor for calling back
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)` to
notify cursor/anchor locations.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#requestCursorUpdates(int)(int cursorUpdateMode)
`

Called by the input method to ask the editor for calling back
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)` to
notify cursor/anchor locations.


`

default


void` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#requestTextBoundsInfo(android.graphics.RectF,%20java.util.concurrent.Executor,%20java.util.function.Consumer<android.view.inputmethod.TextBoundsInfoResult>)(https://developer.android.com/reference/android/graphics/RectF bounds, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfoResult> consumer)
`

Called by input method to request the `https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo` for a range of text which is
covered by or in vicinity of the given `bounds`.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#sendKeyEvent(android.view.KeyEvent)(https://developer.android.com/reference/android/view/KeyEvent event)
`

Send a key event to the process that is currently attached
through this input connection.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#setComposingRegion(int,%20int)(int start, int end)
`

Mark a certain region of text as composing text.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#setComposingRegion(int,%20int,%20android.view.inputmethod.TextAttribute)(int start, int end, https://developer.android.com/reference/android/view/inputmethod/TextAttribute textAttribute)
`

The variant of `https://developer.android.com/reference/android/view/inputmethod/InputConnection#setComposingRegion(int,%20int)`.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#setComposingText(java.lang.CharSequence,%20int,%20android.view.inputmethod.TextAttribute)(https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition, https://developer.android.com/reference/android/view/inputmethod/TextAttribute textAttribute)
`

The variant of `https://developer.android.com/reference/android/view/inputmethod/InputConnection#setComposingText(java.lang.CharSequence,%20int)`.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#setComposingText(java.lang.CharSequence,%20int)(https://developer.android.com/reference/java/lang/CharSequence text, int newCursorPosition)
`

Replace the currently composing text with the given text, and
set the new cursor position.


`

default


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#setImeConsumesInput(boolean)(boolean imeConsumesInput)
`

Called by the input method to indicate that it consumes all input for itself, or no longer
does so.


`
abstract


boolean` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#setSelection(int,%20int)(int start, int end)
`

Set the selection of the text editor.


`

default


https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` `
https://developer.android.com/reference/android/view/inputmethod/InputConnection#takeSnapshot()()
`

Called by the system when it needs to take a snapshot of multiple text-related data in an
atomic manner.


## Public constructors

### BaseInputConnection

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

```
public BaseInputConnection (View targetView, 
                boolean fullEditor)
```

<br />

<br />

| Parameters ||
|---|---|
| `targetView` | `View`: This value cannot be `null`. <br /> |
| `fullEditor` | `boolean` <br /> |

## Public methods

### beginBatchEdit

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

```
public boolean beginBatchEdit ()
```

Default implementation does nothing.

<br />

| Returns ||
|---|---|
| `boolean` | true if a batch edit is now in progress, false otherwise. Since this method starts a batch edit, that means it will always return true unless the input connection is no longer valid. <br /> |

### clearMetaKeyStates

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

```
public boolean clearMetaKeyStates (int states)
```

Default implementation uses `https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(long,%20int)` to clear the state.

<br />

| Parameters ||
|---|---|
| `states` | `int`: The states to be cleared, may be one or more bits as per `https://developer.android.com/reference/android/view/KeyEvent#getMetaState()`. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### closeConnection

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

```
public void closeConnection ()
```

Default implementation calls `https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection#finishComposingText()` and `setImeConsumesInput(false)`.


If you override this method you *must* call through to the
superclass implementation.

<br />

### commitCompletion

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

```
public boolean commitCompletion (CompletionInfo text)
```

Default implementation does nothing and returns false.

<br />

| Parameters ||
|---|---|
| `text` | `CompletionInfo`: The committed completion. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### commitContent

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

```
public boolean commitContent (InputContentInfo inputContentInfo, 
                int flags, 
                Bundle opts)
```

Default implementation which invokes `https://developer.android.com/reference/android/view/View#performReceiveContent(android.view.ContentInfo)` on the target view if
the view `https://developer.android.com/reference/android/view/View#getReceiveContentMimeTypes()` content insertion; otherwise returns
false without any side effects.

<br />

| Parameters ||
|---|---|
| `inputContentInfo` | `InputContentInfo`: Content to be inserted. This value cannot be `null`. <br /> |
| `flags` | `int`: `https://developer.android.com/reference/android/view/inputmethod/InputConnection#INPUT_CONTENT_GRANT_READ_URI_PERMISSION` if the content provider allows `https://developer.android.com/reference/android/R.styleable#AndroidManifestProvider_grantUriPermissions` or `0` if the application does not need to call `https://developer.android.com/reference/android/view/inputmethod/InputContentInfo#requestPermission()`. <br /> |
| `opts` | `Bundle`: optional bundle data. This can be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this request is accepted by the application, whether the request is already handled or still being handled in background, `false` otherwise. <br /> |

### commitCorrection

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

```
public boolean commitCorrection (CorrectionInfo correctionInfo)
```

Default implementation does nothing and returns false.

<br />

| Parameters ||
|---|---|
| `correctionInfo` | `CorrectionInfo`: Detailed information about the correction. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` on success, `false` if the input connection is no longer valid. Since Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N` until `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, this API returned `false` when the target application does not implement this method. <br /> |

### commitText

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

```
public boolean commitText (CharSequence text, 
                int newCursorPosition)
```

Default implementation replaces any existing composing text with the given text. In addition,
only if fallback mode, a key event is sent for the new text and the current editable buffer
cleared.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: The text to commit. This may include styles. <br /> |
| `newCursorPosition` | `int`: The new cursor position around the text, in Java characters. If \> 0, this is relative to the end of the text - 1; if \<= 0, this is relative to the start of the text. So a value of 1 will always advance the cursor to the position after the full text being inserted. Note that this means you can't position the cursor within the text, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### deleteSurroundingText

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

```
public boolean deleteSurroundingText (int beforeLength, 
                int afterLength)
```

The default implementation performs the deletion around the current selection position of the
editable text.

<br />

| Parameters ||
|---|---|
| `beforeLength` | `int`: The number of characters before the cursor to be deleted, in code unit. If this is greater than the number of existing characters between the beginning of the text and the cursor, then this method does not fail but deletes all the characters in that range. <br /> |
| `afterLength` | `int`: The number of characters after the cursor to be deleted, in code unit. If this is greater than the number of existing characters between the cursor and the end of the text, then this method does not fail but deletes all the characters in that range. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` when selected text is deleted, `false` when either the selection is invalid or not yet attached (i.e. selection start or end is -1), or the editable text is `null`. <br /> |

### deleteSurroundingTextInCodePoints

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

```
public boolean deleteSurroundingTextInCodePoints (int beforeLength, 
                int afterLength)
```

The default implementation performs the deletion around the current selection position of the
editable text.

<br />

| Parameters ||
|---|---|
| `beforeLength` | `int`: The number of characters before the cursor to be deleted, in code points. If this is greater than the number of existing characters between the beginning of the text and the cursor, then this method does not fail but deletes all the characters in that range. <br /> |
| `afterLength` | `int`: The number of characters after the cursor to be deleted, in code points. If this is greater than the number of existing characters between the cursor and the end of the text, then this method does not fail but deletes all the characters in that range. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` on success, `false` if the input connection is no longer valid. Before Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, this API returned `false` when the target application does not implement this method. <br /> |

### endBatchEdit

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

```
public boolean endBatchEdit ()
```

Default implementation does nothing.

<br />

| Returns ||
|---|---|
| `boolean` | For editor authors, you must return `true` if a batch edit is still in progress after closing the latest one (in other words, if the nesting count is still a positive number). Return `false` otherwise. For IME authors, you will always receive `true` as long as the request was sent to the editor, and receive `false` only if the input connection is no longer valid. <br /> |

### finishComposingText

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

```
public boolean finishComposingText ()
```

The default implementation removes the composing state from the current editable text. In
addition, only if fallback mode, a key event is sent for the new text and the current
editable buffer cleared.

<br />

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### getComposingSpanEnd

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

```
public static int getComposingSpanEnd (Spannable text)
```

Return the end of the range of composing text, or -1 if there's no composing text.

<br />

| Parameters ||
|---|---|
| `text` | `Spannable`: This value cannot be `null`. <br /> |

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

### getComposingSpanStart

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

```
public static int getComposingSpanStart (Spannable text)
```

Return the beginning of the range of composing text, or -1 if there's no composing text.

<br />

| Parameters ||
|---|---|
| `text` | `Spannable`: This value cannot be `null`. <br /> |

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

### getCursorCapsMode

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

```
public int getCursorCapsMode (int reqModes)
```

The default implementation uses TextUtils.getCapsMode to get the cursor caps mode for the
current selection position in the editable text, unless in fallback mode in which case 0 is
always returned.

<br />

| Parameters ||
|---|---|
| `reqModes` | `int`: The desired modes to retrieve, as defined by `https://developer.android.com/reference/android/text/TextUtils#getCapsMode(java.lang.CharSequence,%20int,%20int)`. These constants are defined so that you can simply pass the current `https://developer.android.com/reference/android/view/inputmethod/EditorInfo#inputType` value directly in to here. <br /> |

| Returns ||
|---|---|
| `int` | the caps mode flags that are in effect at the current cursor position. See TYPE_TEXT_FLAG_CAPS_\* in `https://developer.android.com/reference/android/text/InputType`. <br /> |

### getEditable

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

```
public Editable getEditable ()
```

Return the target of edit operations. The default implementation returns its own fake
editable that is just used for composing text; subclasses that are real text editors should
override this and supply their own.

Subclasses could override this method to turn null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/text/Editable` | <br /> |

### getExtractedText

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

```
public ExtractedText getExtractedText (ExtractedTextRequest request, 
                int flags)
```

The default implementation always returns null.

<br />

| Parameters ||
|---|---|
| `request` | `ExtractedTextRequest`: Description of how the text should be returned. `https://developer.android.com/reference/android/view/inputmethod/ExtractedTextRequest` <br /> |
| `flags` | `int`: Additional options to control the client, either `0` or `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_EXTRACTED_TEXT_MONITOR`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/ExtractedText` | an `https://developer.android.com/reference/android/view/inputmethod/ExtractedText` object describing the state of the text view and containing the extracted text itself, or null if the input connection is no longer valid of the editor can't comply with the request for some reason. <br /> |

### getHandler

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

```
public Handler getHandler ()
```

Called by the system to enable application developers to specify a dedicated thread on which
`https://developer.android.com/reference/android/view/inputmethod/InputConnection` methods are called back.

**Editor authors** : although you can return your custom subclasses of
`https://developer.android.com/reference/android/os/Handler`, the system only uses `https://developer.android.com/reference/android/os/Looper` returned from
`https://developer.android.com/reference/android/os/Handler#getLooper()`. You cannot intercept or cancel `https://developer.android.com/reference/android/view/inputmethod/InputConnection`
callbacks by implementing this method.

**IME authors** : This method is not intended to be called from the IME. You
will always receive `null`.

<br />

<br />

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

### getSelectedText

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

```
public CharSequence getSelectedText (int flags)
```

The default implementation returns the text currently selected, or null if none is selected.

<br />

| Parameters ||
|---|---|
| `flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_TEXT_WITH_STYLES`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | the text that is currently selected, if any, or `null` if no text is selected. <br /> |

### getSurroundingText

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

```
public SurroundingText getSurroundingText (int beforeLength, 
                int afterLength, 
                int flags)
```

The default implementation returns the given amount of text around the current cursor
position in the buffer.

<br />

| Parameters ||
|---|---|
| `beforeLength` | `int`: Value is 0 or greater <br /> |
| `afterLength` | `int`: Value is 0 or greater <br /> |
| `flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_TEXT_WITH_STYLES`. Value is either `0` or - `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_TEXT_WITH_STYLES` |

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

### getTextAfterCursor

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

```
public CharSequence getTextAfterCursor (int length, 
                int flags)
```

The default implementation returns the given amount of text from the current cursor position
in the buffer.

<br />

| Parameters ||
|---|---|
| `length` | `int`: Value is 0 or greater <br /> |
| `flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_TEXT_WITH_STYLES`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | This value may be `null`. <br /> |

### getTextBeforeCursor

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

```
public CharSequence getTextBeforeCursor (int length, 
                int flags)
```

The default implementation returns the given amount of text from the current cursor position
in the buffer.

<br />

| Parameters ||
|---|---|
| `length` | `int`: Value is 0 or greater <br /> |
| `flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `https://developer.android.com/reference/android/view/inputmethod/InputConnection#GET_TEXT_WITH_STYLES`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | This value may be `null`. <br /> |

### performContextMenuAction

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

```
public boolean performContextMenuAction (int id)
```

The default implementation does nothing.

<br />

| Parameters ||
|---|---|
| `id` | `int` <br /> |

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

### performEditorAction

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

```
public boolean performEditorAction (int actionCode)
```

The default implementation turns this into the enter key.

<br />

| Parameters ||
|---|---|
| `actionCode` | `int`: This must be one of the action constants for `https://developer.android.com/reference/android/view/inputmethod/EditorInfo#imeOptions`, such as `https://developer.android.com/reference/android/view/inputmethod/EditorInfo#IME_ACTION_GO`, or the value of `https://developer.android.com/reference/android/view/inputmethod/EditorInfo#actionId` if a custom action is available. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### performPrivateCommand

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

```
public boolean performPrivateCommand (String action, 
                Bundle data)
```

The default implementation does nothing.

<br />

| Parameters ||
|---|---|
| `action` | `String`: Name of the command to be performed. This *must* be a scoped name, i.e. prefixed with a package name you own, so that different developers will not create conflicting commands. <br /> |
| `data` | `Bundle`: Any data to include with the command. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the command was sent (whether or not the associated editor understood it), false if the input connection is no longer valid. <br /> |

### removeComposingSpans

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

```
public static final void removeComposingSpans (Spannable text)
```

Removes the composing spans from the given text if any.

<br />

| Parameters ||
|---|---|
| `text` | `Spannable`: the spannable text to remove composing spans. This value cannot be `null`. <br /> |

### replaceText

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

```
public boolean replaceText (int start, 
                int end, 
                CharSequence text, 
                int newCursorPosition, 
                TextAttribute textAttribute)
```

Replace the specific range in the editor with suggested text.

This method finishes whatever composing text is currently active and leaves the text
as-it, replaces the specific range of text with the passed CharSequence, and then moves the
cursor according to `newCursorPosition`. This behaves like calling `https://developer.android.com/reference/android/view/inputmethod/InputConnection#finishComposingText()`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#setSelection(int,%20int)`, and then
`https://developer.android.com/reference/android/view/inputmethod/InputConnection#commitText(java.lang.CharSequence,%20int,%20android.view.inputmethod.TextAttribute)`.

Similar to `https://developer.android.com/reference/android/view/inputmethod/InputConnection#setSelection(int,%20int)`, the order of start and end is not important.
In effect, the region from start to end and the region from end to start is the same. Editor
authors, be ready to accept a start that is greater than end.

<br />

| Parameters ||
|---|---|
| `start` | `int`: Value is 0 or greater <br /> |
| `end` | `int`: Value is 0 or greater <br /> |
| `text` | `CharSequence`: This value cannot be `null`. <br /> |
| `newCursorPosition` | `int`: the new cursor position around the text. If \> 0, this is relative to the end of the text - 1; if \<= 0, this is relative to the start of the text. So a value of 1 will always advance you to the position after the full text being inserted. Note that this means you can't position the cursor within the text. <br /> |
| `textAttribute` | `TextAttribute`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the replace command was sent to the associated editor (regardless of whether the replacement is success or not), `false` otherwise. <br /> |

### reportFullscreenMode

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

```
public boolean reportFullscreenMode (boolean enabled)
```

Updates InputMethodManager with the current fullscreen mode.

<br />

| Parameters ||
|---|---|
| `enabled` | `boolean` <br /> |

| Returns ||
|---|---|
| `boolean` | For editor authors, the return value will always be ignored. For IME authors, this always returns `true` on `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N_MR1` and prior devices and `false` on `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O` and later devices. <br /> |

### requestCursorUpdates

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

```
public boolean requestCursorUpdates (int cursorUpdateMode)
```

The default implementation does nothing.

<br />

| Parameters ||
|---|---|
| `cursorUpdateMode` | `int`: any combination of update modes and filters: `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_IMMEDIATE`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_MONITOR`, and data filters: `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_CHARACTER_BOUNDS`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_EDITOR_BOUNDS`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_INSERTION_MARKER`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_VISIBLE_LINE_BOUNDS`, `https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_FILTER_TEXT_APPEARANCE`. Pass `0` to disable them. However, if an unknown flag is provided, request will be rejected and method will return `false`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the request is scheduled. `false` to indicate that when the application will not call `https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateCursorAnchorInfo(android.view.View,%20android.view.inputmethod.CursorAnchorInfo)`. Since Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N` until `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, this API returned `false` when the target application does not implement this method. <br /> |

### sendKeyEvent

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

```
public boolean sendKeyEvent (KeyEvent event)
```

Provides standard implementation for sending a key event to the window attached to the input
connection's view.

<br />

| Parameters ||
|---|---|
| `event` | `KeyEvent`: The key event. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### setComposingRegion

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

```
public boolean setComposingRegion (int start, 
                int end)
```

Mark a certain region of text as composing text. If there was a
composing region, the characters are left as they were and the
composing span removed, as if `https://developer.android.com/reference/android/view/inputmethod/InputConnection#finishComposingText()`
has been called. The default style for composing text is used.

The passed indices are clipped to the contents bounds. If
the resulting region is zero-sized, no region is marked and the
effect is the same as that of calling `https://developer.android.com/reference/android/view/inputmethod/InputConnection#finishComposingText()`.
The order of start and end is not important. In effect, the
region from start to end and the region from end to start is
the same. Editor authors, be ready to accept a start that is
greater than end.

Since this does not change the contents of the text, editors should not call
`https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#updateSelection(android.view.View,%20int,%20int,%20int,%20int)` and
IMEs should not receive
`https://developer.android.com/reference/android/inputmethodservice/InputMethodService#onUpdateSelection(int,%20int,%20int,%20int,%20int,%20int)`.

This has no impact on the cursor/selection position. It may
result in the cursor being anywhere inside or outside the
composing region, including cases where the selection and the
composing region overlap partially or entirely.

<br />

<br />

| Parameters ||
|---|---|
| `start` | `int`: the position in the text at which the composing region begins <br /> |
| `end` | `int`: the position in the text at which the composing region ends <br /> |

| Returns ||
|---|---|
| `boolean` | `true` on success, `false` if the input connection is no longer valid. Since Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N` until `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, this API returned `false` when the target application does not implement this method. <br /> |

### setComposingSpans

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

```
public static void setComposingSpans (Spannable text)
```

Removes the composing spans from the given text if any.

<br />

| Parameters ||
|---|---|
| `text` | `Spannable`: the spannable text to remove composing spans. This value cannot be `null`. <br /> |

### setComposingText

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

```
public boolean setComposingText (CharSequence text, 
                int newCursorPosition)
```

The default implementation places the given text into the editable, replacing any existing
composing text. The new text is marked as in a composing state with the composing style.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: The composing text with styles if necessary. If no style object attached to the text, the default style for composing text is used. See `https://developer.android.com/reference/android/text/Spanned` for how to attach style object to the text. `https://developer.android.com/reference/android/text/SpannableString` and `https://developer.android.com/reference/android/text/SpannableStringBuilder` are two implementations of the interface `https://developer.android.com/reference/android/text/Spanned`. <br /> |
| `newCursorPosition` | `int`: The new cursor position around the text. If \> 0, this is relative to the end of the text - 1; if \<= 0, this is relative to the start of the text. So a value of 1 will always advance you to the position after the full text being inserted. Note that this means you can't position the cursor within the text, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### setSelection

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

```
public boolean setSelection (int start, 
                int end)
```

The default implementation changes the selection position in the current editable text.

<br />

| Parameters ||
|---|---|
| `start` | `int`: the character index where the selection should start. <br /> |
| `end` | `int`: the character index where the selection should end. <br /> |

| Returns ||
|---|---|
| `boolean` | true on success, false if the input connection is no longer valid. <br /> |

### takeSnapshot

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

```
public TextSnapshot takeSnapshot ()
```

Default implementation that constructs `https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` with information extracted from
`https://developer.android.com/reference/android/view/inputmethod/BaseInputConnection`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` | `null` when `https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` cannot be fully taken. <br /> |