# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Inherited Constants | Ctors | Methods | Inherited Methods

# BaseInputConnection

`public class BaseInputConnection`
`extends Object` `implements InputConnection`

java.lang.Object
↳ | android.view.inputmethod.BaseInputConnection

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 `getEditable()` to provide access to their own editable object, and to refer to the documentation in `InputConnection`.

## Summary

### Inherited constants
From interface `android.view.inputmethod.InputConnection`
`int` | `CURSOR_UPDATE_IMMEDIATE` The editor is requested to call `InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)` at once, as soon as possible, regardless of cursor/anchor position changes.
`int` | `CURSOR_UPDATE_MONITOR` The editor is requested to call `InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)` whenever cursor/anchor position is changed.
`int` | `GET_EXTRACTED_TEXT_MONITOR` Flag for use with `getExtractedText(ExtractedTextRequest, int)` to indicate you would like to receive updates when the extracted text changes.
`int` | `GET_TEXT_WITH_STYLES` Flag for use with `getTextAfterCursor(int, int)`, `getTextBeforeCursor(int, int)` and `getSurroundingText(int, int, int)` to have style information returned along with the text.
`int` | `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 `InputContentInfo` object.

### Public constructors
`BaseInputConnection(View targetView, boolean fullEditor)`

### Public methods
`boolean` | `beginBatchEdit()` Default implementation does nothing.
`boolean` | `clearMetaKeyStates(int states)` Default implementation uses `MetaKeyKeyListener.clearMetaKeyState(long, int)` to clear the state.
`void` | `closeConnection()` Default implementation calls `finishComposingText()` and `setImeConsumesInput(false)`.
`boolean` | `commitCompletion(CompletionInfo text)` Default implementation does nothing and returns false.
`boolean` | `commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts)` Default implementation which invokes `View#performReceiveContent` on the target view if the view `allows` content insertion; otherwise returns false without any side effects.
`boolean` | `commitCorrection(CorrectionInfo correctionInfo)` Default implementation does nothing and returns false.
`boolean` | `commitText(CharSequence text, int newCursorPosition)` Default implementation replaces any existing composing text with the given text.
`boolean` | `deleteSurroundingText(int beforeLength, int afterLength)` The default implementation performs the deletion around the current selection position of the editable text.
`boolean` | `deleteSurroundingTextInCodePoints(int beforeLength, int afterLength)` The default implementation performs the deletion around the current selection position of the editable text.
`boolean` | `endBatchEdit()` Default implementation does nothing.
`boolean` | `finishComposingText()` The default implementation removes the composing state from the current editable text.
`static int` | `getComposingSpanEnd(Spannable text)`
`static int` | `getComposingSpanStart(Spannable text)`
`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.
`Editable` | `getEditable()` Return the target of edit operations.
`ExtractedText` | `getExtractedText(ExtractedTextRequest request, int flags)` The default implementation always returns null.
`Handler` | `getHandler()` Called by the `InputMethodManager` to enable application developers to specify a dedicated `Handler` on which incoming IPC method calls from input methods will be dispatched.
`CharSequence` | `getSelectedText(int flags)` The default implementation returns the text currently selected, or null if none is selected.
`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.
`CharSequence` | `getTextAfterCursor(int length, int flags)` The default implementation returns the given amount of text from the current cursor position in the buffer.
`CharSequence` | `getTextBeforeCursor(int length, int flags)` The default implementation returns the given amount of text from the current cursor position in the buffer.
`boolean` | `performContextMenuAction(int id)` The default implementation does nothing.
`boolean` | `performEditorAction(int actionCode)` The default implementation turns this into the enter key.
`boolean` | `performPrivateCommand(String action, Bundle data)` The default implementation does nothing.
`static final void` | `removeComposingSpans(Spannable text)`
`boolean` | `reportFullscreenMode(boolean enabled)` Updates InputMethodManager with the current fullscreen mode.
`boolean` | `requestCursorUpdates(int cursorUpdateMode)` The default implementation does nothing.
`boolean` | `sendKeyEvent(KeyEvent event)` Provides standard implementation for sending a key event to the window attached to the input connection's view.
`boolean` | `setComposingRegion(int start, int end)` Mark a certain region of text as composing text.
`static void` | `setComposingSpans(Spannable text)`
`boolean` | `setComposingText(CharSequence text, int newCursorPosition)` The default implementation places the given text into the editable, replacing any existing composing text.
`boolean` | `setSelection(int start, int end)` The default implementation changes the selection position in the current editable text.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `android.view.inputmethod.InputConnection`
`abstract boolean` | `beginBatchEdit()` Tell the editor that you are starting a batch of editor operations.
`abstract boolean` | `clearMetaKeyStates(int states)` Clear the given meta key pressed states in the given input connection.
`abstract void` | `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` | `commitCompletion(CompletionInfo text)` Commit a completion the user has selected from the possible ones previously reported to `InputMethodSession#displayCompletions(CompletionInfo[])` or `InputMethodManager#displayCompletions(View, CompletionInfo[])`.
`abstract boolean` | `commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts)` Called by the input method to commit content such as a PNG image to the editor.
`abstract boolean` | `commitCorrection(CorrectionInfo correctionInfo)` Commit a correction automatically performed on the raw user's input.
`abstract boolean` | `commitText(CharSequence text, int newCursorPosition)` Commit text to the text box and set the new cursor position.
`abstract boolean` | `deleteSurroundingText(int beforeLength, int afterLength)` Delete beforeLength characters of text before the current cursor position, and delete afterLength characters of text after the current cursor position, excluding the selection.
`abstract boolean` | `deleteSurroundingTextInCodePoints(int beforeLength, int afterLength)` A variant of `deleteSurroundingText(int, int)`.
`abstract boolean` | `endBatchEdit()` Tell the editor that you are done with a batch edit previously initiated with `beginBatchEdit()`.
`abstract boolean` | `finishComposingText()` Have the text editor finish whatever composing text is currently active.
`abstract int` | `getCursorCapsMode(int reqModes)` Retrieve the current capitalization mode in effect at the current cursor position in the text.
`abstract ExtractedText` | `getExtractedText(ExtractedTextRequest request, int flags)` Retrieve the current text in the input connection's editor, and monitor for any changes to it.
`abstract Handler` | `getHandler()` Called by the `InputMethodManager` to enable application developers to specify a dedicated `Handler` on which incoming IPC method calls from input methods will be dispatched.
`abstract CharSequence` | `getSelectedText(int flags)` Gets the selected text, if any.
`default SurroundingText` | `getSurroundingText(int beforeLength, int afterLength, int flags)` Gets the surrounding text around the current cursor, with beforeLength characters of text before the cursor (start of the selection), afterLength characters of text after the cursor (end of the selection), and all of the selected text.
`abstract CharSequence` | `getTextAfterCursor(int n, int flags)` Get n characters of text after the current cursor position.
`abstract CharSequence` | `getTextBeforeCursor(int n, int flags)` Get n characters of text before the current cursor position.
`abstract boolean` | `performContextMenuAction(int id)` Perform a context menu action on the field.
`abstract boolean` | `performEditorAction(int editorAction)` Have the editor perform an action it has said it can do.
`abstract boolean` | `performPrivateCommand(String action, Bundle data)` API to send private commands from an input method to its connected editor.
`default boolean` | `performSpellCheck()` Have the editor perform spell checking for the full content.
`abstract boolean` | `reportFullscreenMode(boolean enabled)` Called back when the connected IME switches between fullscreen and normal modes.
`abstract boolean` | `requestCursorUpdates(int cursorUpdateMode)` Called by the input method to ask the editor for calling back `InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)` to notify cursor/anchor locations.
`abstract boolean` | `sendKeyEvent(KeyEvent event)` Send a key event to the process that is currently attached through this input connection.
`abstract boolean` | `setComposingRegion(int start, int end)` Mark a certain region of text as composing text.
`abstract boolean` | `setComposingText(CharSequence text, int newCursorPosition)` Replace the currently composing text with the given text, and set the new cursor position.
`default boolean` | `setImeConsumesInput(boolean imeConsumesInput)` Called by the input method to indicate that it consumes all input for itself, or no longer does so.
`abstract boolean` | `setSelection(int start, int end)` Set the selection of the text editor.

## Public constructors

### BaseInputConnection

    public BaseInputConnection (View targetView,
                    boolean fullEditor)

Parameters
`targetView` | `View`
`fullEditor` | `boolean`

## Public methods

### beginBatchEdit

    public boolean beginBatchEdit ()

Default implementation does nothing.

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.

### clearMetaKeyStates

    public boolean clearMetaKeyStates (int states)

Default implementation uses `MetaKeyKeyListener.clearMetaKeyState(long, int)` to clear the state.

Parameters
`states` | `int`: The states to be cleared, may be one or more bits as per `KeyEvent.getMetaState()`.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### closeConnection

    public void closeConnection ()

Default implementation calls `finishComposingText()` and `setImeConsumesInput(false)`.
If you override this method you must call through to the superclass implementation.

### commitCompletion

    public boolean commitCompletion (CompletionInfo text)

Default implementation does nothing and returns false.

Parameters
`text` | `CompletionInfo`: The committed completion.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### commitContent

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

Default implementation which invokes `View#performReceiveContent` on the target view if the view `allows` content insertion; otherwise returns false without any side effects.

Parameters
`inputContentInfo` | `InputContentInfo`: Content to be inserted. This value cannot be `null`.
`flags` | `int`: `InputConnection.INPUT_CONTENT_GRANT_READ_URI_PERMISSION` if the content provider allows `grantUriPermissions` or `0` if the application does not need to call `InputContentInfo#requestPermission()`.
`opts` | `Bundle`: optional bundle data. This can be `null`. This value may be `null`.

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.

### commitCorrection

    public boolean commitCorrection (CorrectionInfo correctionInfo)

Default implementation does nothing and returns false.

Parameters
`correctionInfo` | `CorrectionInfo`: Detailed information about the correction.

Returns
`boolean` | true on success, false if the input connection is no longer valid. In `Build.VERSION_CODES.N` and later, returns false when the target application does not implement this method.

### commitText

    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.

Parameters
`text` | `CharSequence`: The text to commit. This may include styles.
`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.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### deleteSurroundingText

    public boolean deleteSurroundingText (int beforeLength,
                    int afterLength)

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

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.
`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.

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`.

### deleteSurroundingTextInCodePoints

    public boolean deleteSurroundingTextInCodePoints (int beforeLength,
                    int afterLength)

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

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.
`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.

Returns
`boolean` | true on success, false if the input connection is no longer valid. Returns `false` when the target application does not implement this method.

### endBatchEdit

    public boolean endBatchEdit ()

Default implementation does nothing.

Returns
`boolean` | true if there is still a batch edit in progress after closing the latest one (in other words, if the nesting count is > 0), false otherwise or if the input connection is no longer valid.

### finishComposingText

    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.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### getComposingSpanEnd

    public static int getComposingSpanEnd (Spannable text)

Parameters
`text` | `Spannable`

Returns
`int` |

### getComposingSpanStart

    public static int getComposingSpanStart (Spannable text)

Parameters
`text` | `Spannable`

Returns
`int` |

### getCursorCapsMode

    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.

Parameters
`reqModes` | `int`: The desired modes to retrieve, as defined by `TextUtils.getCapsMode`. These constants are defined so that you can simply pass the current `TextBoxAttribute.contentType` value directly in to here.

Returns
`int` | the caps mode flags that are in effect at the current cursor position. See TYPE_TEXT_FLAG_CAPS_* in `InputType`.

### getEditable

    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.

Returns
`Editable` |

### getExtractedText

    public ExtractedText getExtractedText (ExtractedTextRequest request,
                    int flags)

The default implementation always returns null.

Parameters
`request` | `ExtractedTextRequest`: Description of how the text should be returned. `ExtractedTextRequest`
`flags` | `int`: Additional options to control the client, either `0` or `InputConnection.GET_EXTRACTED_TEXT_MONITOR`.

Returns
`ExtractedText` | an `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.

### getHandler

    public Handler getHandler ()

Called by the `InputMethodManager` to enable application developers to specify a dedicated `Handler` on which incoming IPC method calls from input methods will be dispatched.

Note: This does nothing when called from input methods.

Returns
`Handler` | `null` to use the default `Handler`.

### getSelectedText

    public CharSequence getSelectedText (int flags)

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

Parameters
`flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `InputConnection.GET_TEXT_WITH_STYLES`.

Returns
`CharSequence` | the text that is currently selected, if any, or null if no text is selected. In `Build.VERSION_CODES.N` and later, returns false when the target application does not implement this method.

### getSurroundingText

    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.

Parameters
`beforeLength` | `int`: Value is 0 or greater
`afterLength` | `int`: Value is 0 or greater
`flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `InputConnection.GET_TEXT_WITH_STYLES`. Value is either `0` or `InputConnection.GET_TEXT_WITH_STYLES`

Returns
`SurroundingText` | This value may be `null`.

### getTextAfterCursor

    public CharSequence getTextAfterCursor (int length,
                    int flags)

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

Parameters
`length` | `int`: Value is 0 or greater
`flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `InputConnection.GET_TEXT_WITH_STYLES`.

Returns
`CharSequence` | This value may be `null`.

### getTextBeforeCursor

    public CharSequence getTextBeforeCursor (int length,
                    int flags)

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

Parameters
`length` | `int`: Value is 0 or greater
`flags` | `int`: Supplies additional options controlling how the text is returned. May be either `0` or `InputConnection.GET_TEXT_WITH_STYLES`.

Returns
`CharSequence` | This value may be `null`.

### performContextMenuAction

    public boolean performContextMenuAction (int id)

The default implementation does nothing.

Parameters
`id` | `int`

Returns
`boolean` |

### performEditorAction

    public boolean performEditorAction (int actionCode)

The default implementation turns this into the enter key.

Parameters
`actionCode` | `int`: This must be one of the action constants for `EditorInfo.editorType`, such as `EditorInfo.EDITOR_ACTION_GO`.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### performPrivateCommand

    public boolean performPrivateCommand (String action,
                    Bundle data)

The default implementation does nothing.

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.
`data` | `Bundle`: Any data to include with the command.

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.

### removeComposingSpans

    public static final void removeComposingSpans (Spannable text)

Parameters
`text` | `Spannable`

### reportFullscreenMode

    public boolean reportFullscreenMode (boolean enabled)

Updates InputMethodManager with the current fullscreen mode.

Parameters
`enabled` | `boolean`

Returns
`boolean` | For editor authors, the return value will always be ignored. For IME authors, this always returns `true` on `Build.VERSION_CODES.N_MR1` and prior devices and `false` on `Build.VERSION_CODES.O` and later devices.

### requestCursorUpdates

    public boolean requestCursorUpdates (int cursorUpdateMode)

The default implementation does nothing.

Parameters
`cursorUpdateMode` | `int`: `InputConnection.CURSOR_UPDATE_IMMEDIATE` and/or `InputConnection.CURSOR_UPDATE_MONITOR`. Pass `0` to disable the effect of `InputConnection.CURSOR_UPDATE_MONITOR`.

Returns
`boolean` | `true` if the request is scheduled. `false` to indicate that when the application will not call `InputMethodManager#updateCursorAnchorInfo(android.view.View, CursorAnchorInfo)`. In `Build.VERSION_CODES.N` and later, returns `false` also when the target application does not implement this method.

### sendKeyEvent

    public boolean sendKeyEvent (KeyEvent event)

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

Parameters
`event` | `KeyEvent`: The key event.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### setComposingRegion

    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 `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 `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 `InputMethodManager#updateSelection(View, int, int, int, int)` and IMEs should not receive `InputMethodService.onUpdateSelection(int, int, int, int, int, int)`.

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.

Parameters
`start` | `int`: the position in the text at which the composing region begins
`end` | `int`: the position in the text at which the composing region ends

Returns
`boolean` | true on success, false if the input connection is no longer valid. In `Build.VERSION_CODES.N` and later, false is returned when the target application does not implement this method.

### setComposingSpans

    public static void setComposingSpans (Spannable text)

Parameters
`text` | `Spannable`

### setComposingText

    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.

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 `Spanned` for how to attach style object to the text. `SpannableString` and `SpannableStringBuilder` are two implementations of the interface `Spanned`.
`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.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

### setSelection

    public boolean setSelection (int start,
                    int end)

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

Parameters
`start` | `int`: the character index where the selection should start.
`end` | `int`: the character index where the selection should end.

Returns
`boolean` | true on success, false if the input connection is no longer valid.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*