Most visited

Recently visited

Added in API level 3

InputMethodSession

public interface InputMethodSession

android.view.inputmethod.InputMethodSession
Known Indirect Subclasses


The InputMethodSession interface provides the per-client functionality of InputMethod that is safe to expose to applications.

Applications will not normally use this interface themselves, instead relying on the standard interaction provided by TextView and EditText.

Summary

Nested classes

interface InputMethodSession.EventCallback

 

Public methods

abstract void appPrivateCommand(String action, Bundle data)

Process a private command sent from the application to the input method.

abstract void dispatchGenericMotionEvent(int seq, MotionEvent event, InputMethodSession.EventCallback callback)

This method is called when there is a generic motion event.

abstract void dispatchKeyEvent(int seq, KeyEvent event, InputMethodSession.EventCallback callback)

This method is called when a key is pressed.

abstract void dispatchTrackballEvent(int seq, MotionEvent event, InputMethodSession.EventCallback callback)

This method is called when there is a track ball event.

abstract void displayCompletions(CompletionInfo[] completions)

Called by a text editor that performs auto completion, to tell the input method about the completions it has available.

abstract void finishInput()

This method is called when the application would like to stop receiving text input.

abstract void toggleSoftInput(int showFlags, int hideFlags)

Toggle the soft input window.

abstract void updateCursor(Rect newCursor)

This method is called when cursor location of the target input field has changed within its window.

abstract void updateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo)

This method is called when the cursor and/or the character position relevant to text input is changed on the screen.

abstract void updateExtractedText(int token, ExtractedText text)

Called by a text editor to report its new extracted text when its contents change.

abstract void updateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd)

This method is called when the selection or cursor in the current target input field has changed.

abstract void viewClicked(boolean focusChanged)

This method is called when the user tapped a text view.

Public methods

appPrivateCommand

Added in API level 3
void appPrivateCommand (String action, 
                Bundle data)

Process a private command sent from the application to the input method. This can be used to provide domain-specific features that are only known between certain input methods and their clients.

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.

dispatchGenericMotionEvent

Added in API level 17
void dispatchGenericMotionEvent (int seq, 
                MotionEvent event, 
                InputMethodSession.EventCallback callback)

This method is called when there is a generic motion event.

If the input method wants to handle this event, return true, otherwise return false and the caller (i.e. the application) will handle the event.

Parameters
seq int
event MotionEvent: The motion event.
callback InputMethodSession.EventCallback
Returns
void Whether the input method wants to handle this event.

See also:

dispatchKeyEvent

Added in API level 3
void dispatchKeyEvent (int seq, 
                KeyEvent event, 
                InputMethodSession.EventCallback callback)

This method is called when a key is pressed. When done with the event, the implementation must call back on callback with its result.

If the input method wants to handle this event, return true, otherwise return false and the caller (i.e. the application) will handle the event.

Parameters
seq int
event KeyEvent: The key event.
callback InputMethodSession.EventCallback
Returns
void Whether the input method wants to handle this event.

See also:

dispatchTrackballEvent

Added in API level 3
void dispatchTrackballEvent (int seq, 
                MotionEvent event, 
                InputMethodSession.EventCallback callback)

This method is called when there is a track ball event.

If the input method wants to handle this event, return true, otherwise return false and the caller (i.e. the application) will handle the event.

Parameters
seq int
event MotionEvent: The motion event.
callback InputMethodSession.EventCallback
Returns
void Whether the input method wants to handle this event.

See also:

displayCompletions

Added in API level 3
void displayCompletions (CompletionInfo[] completions)

Called by a text editor that performs auto completion, to tell the input method about the completions it has available. This can be used by the input method to display them to the user to select the text to be inserted.

Parameters
completions CompletionInfo: Array of text completions that are available, starting with the best. If this array is null, any existing completions will be removed.

finishInput

Added in API level 3
void finishInput ()

This method is called when the application would like to stop receiving text input.

toggleSoftInput

Added in API level 3
void toggleSoftInput (int showFlags, 
                int hideFlags)

Toggle the soft input window. Applications can toggle the state of the soft input window.

Parameters
showFlags int: Provides additional operating flags. May be 0 or have the SHOW_IMPLICIT, SHOW_FORCED bit set.
hideFlags int: Provides additional operating flags. May be 0 or have the HIDE_IMPLICIT_ONLY, HIDE_NOT_ALWAYS bit set.

updateCursor

Added in API level 3
void updateCursor (Rect newCursor)

This method is called when cursor location of the target input field has changed within its window. This is not normally called, but will only be reported if requested by the input method.

Parameters
newCursor Rect: The rectangle of the cursor currently being shown in the input field's window coordinates.

updateCursorAnchorInfo

Added in API level 21
void updateCursorAnchorInfo (CursorAnchorInfo cursorAnchorInfo)

This method is called when the cursor and/or the character position relevant to text input is changed on the screen. This is not called by default. It will only be reported if requested by the input method.

Parameters
cursorAnchorInfo CursorAnchorInfo: Positional information relevant to text input, such as text insertion point and composition string.

updateExtractedText

Added in API level 3
void updateExtractedText (int token, 
                ExtractedText text)

Called by a text editor to report its new extracted text when its contents change. This will only be called if the input method calls InputConnection.getExtractedText() with the option to report updates.

Parameters
token int: The input method supplied token for identifying its request.
text ExtractedText: The new extracted text.

updateSelection

Added in API level 3
void updateSelection (int oldSelStart, 
                int oldSelEnd, 
                int newSelStart, 
                int newSelEnd, 
                int candidatesStart, 
                int candidatesEnd)

This method is called when the selection or cursor in the current target input field has changed.

Parameters
oldSelStart int: The previous text offset of the cursor selection start position.
oldSelEnd int: The previous text offset of the cursor selection end position.
newSelStart int: The new text offset of the cursor selection start position.
newSelEnd int: The new text offset of the cursor selection end position.
candidatesStart int: The text offset of the current candidate text start position.
candidatesEnd int: The text offset of the current candidate text end position.

viewClicked

Added in API level 14
void viewClicked (boolean focusChanged)

This method is called when the user tapped a text view. IMEs can't rely on this method being called because this was not part of the original IME protocol, so applications with custom text editing written before this method appeared will not call to inform the IME of this interaction.

Parameters
focusChanged boolean: true if the user changed the focused view by this click.

Hooray!