Android InputConnection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android InputConnection class.

This code example shows how to use the following methods: finishComposingText, getTextBeforeCursor, setComposingText
        if (connection == null) {
            return; 
        } 
 
        // Commit the composing text 
        connection.finishComposingText();
 
        // Add a space if the field already has text. 
        String text = newText;
        CharSequence charBeforeCursor = connection.getTextBeforeCursor(1, 0);
        if (charBeforeCursor != null
                && !charBeforeCursor.equals(" ")
                && (charBeforeCursor.length() > 0)) {
            text = " " + text;
        } 
 
        connection.setComposingText(text, 1);
    } 
 
    private static int getCursorPosition(InputConnection connection) {

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commitCorrection
	} 
	 
	@Override 
	public void commitCorrectionToInputConnection(InputConnection ic,
			WordComposer word) {
		super.commitCorrectionToInputConnection(ic, word);
		CorrectionInfo correctionInfo = new CorrectionInfo(
				word.globalCursorPosition() - word.getTypedWord().length(),
				word.getTypedWord(), word.getPreferredWord());
 
		ic.commitCorrection(correctionInfo);
	} 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commitText, deleteSurroundingText, getTextBeforeCursor
        if (null == inputContext || null == event) return false;
 
        int keyCode = event.getKeyCode();
 
        CharSequence prefix = null;
        prefix = inputContext.getTextBeforeCursor(2, 0);
 
        int keyChar;
        keyChar = 0;
        if (keyCode >= KeyEvent.KEYCODE_A && keyCode <= KeyEvent.KEYCODE_Z) {
            keyChar = keyCode - KeyEvent.KEYCODE_A + 'a';
            if (upperCase) {
                keyChar = keyChar + 'A' - 'a';
            } 
        } else if (keyCode >= KeyEvent.KEYCODE_0
                && keyCode <= KeyEvent.KEYCODE_9)
            keyChar = keyCode - KeyEvent.KEYCODE_0 + '0';
        else if (keyCode == KeyEvent.KEYCODE_COMMA)
            keyChar = ',';
        else if (keyCode == KeyEvent.KEYCODE_PERIOD)

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commitText, deleteSurroundingText, getTextBeforeCursor
        if (null == inputContext || null == event) return false;
 
        int keyCode = event.getKeyCode();
 
        CharSequence prefix = null;
        prefix = inputContext.getTextBeforeCursor(2, 0);
 
        int keyChar;
        keyChar = 0;
        if (keyCode >= KeyEvent.KEYCODE_A && keyCode <= KeyEvent.KEYCODE_Z) {
            keyChar = keyCode - KeyEvent.KEYCODE_A + 'a';
            if (upperCase) {
                keyChar = keyChar + 'A' - 'a';
            } 
        } else if (keyCode >= KeyEvent.KEYCODE_0
                && keyCode <= KeyEvent.KEYCODE_9)
            keyChar = keyCode - KeyEvent.KEYCODE_0 + '0';
        else if (keyCode == KeyEvent.KEYCODE_COMMA)
            keyChar = ',';
        else if (keyCode == KeyEvent.KEYCODE_PERIOD)

-16
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: beginBatchEdit, commitText, endBatchEdit
   */ 
  public boolean commitText(InputConnection ic, CharSequence text) {
    if (ic != null) {
      if (text.length() > 1) {
        // Batch edit a sequence of characters. 
        ic.beginBatchEdit();
        ic.commitText(text, 1);
        ic.endBatchEdit();
      } else { 
        ic.commitText(text, 1);
      } 
      // Composing-text in the editor has been cleared. 
      composingText.setLength(0);
      return true; 
    } 
    return false; 
  } 
 
  public boolean treatEnterAsLinkBreak() { 
    return enterAsLineBreak;
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android InputConnection Questions & Answers:

See Code Examples for Android InputConnection Methods: