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
This code example shows how to use the following methods: getExtractedText
        InputConnection conn, Bundle bundle) {
        if (conn == null) {
            return; 
        } 
 
        ExtractedText et = conn.getExtractedText(new ExtractedTextRequest(), 0);
        if (et == null) {
            return; 
        } 
        bundle.putBoolean(SINGLE_LINE, (et.flags & et.FLAG_SINGLE_LINE) > 0);
    } 
     
    private static void addLanguageInfoToBundle( 
            String selectedLanguage, String[] enabledLanguages, Bundle bundle) {
        bundle.putString(SELECTED_LANGUAGE, selectedLanguage);
        bundle.putStringArray(ENABLED_LANGUAGES, enabledLanguages);
    } 
 
    public Bundle getBundle() {
        return mFieldInfo;
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: 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
This code example shows how to use the following methods: commitText
			AskOnGestureListener listener) {
		return new GestureDetector(appContext, listener, null);
	} 
	 
	public void commitCorrectionToInputConnection(InputConnection ic, WordComposer word) {
		ic.commitText(word.getPreferredWord(), 1);
	} 
} 
Full Snippet Info
5
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: 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) {

5
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
    outInsets.contentTopInsets = outInsets.visibleTopInsets;
  } 
 
  @Override 
  public View onCreateInputView() {
    inputView = (SoftKeyboardView) getLayoutInflater().inflate(
        R.layout.input, null); 
    inputView.setOnKeyboardActionListener(this);
    return inputView;
  } 
 
  @Override 
  public View onCreateCandidatesView() {
    candidatesContainer = (CandidatesContainer) getLayoutInflater().inflate(
        R.layout.candidates, null); 
    candidatesContainer.setCandidateViewListener(this);
    return candidatesContainer;
  } 
 
  @Override 
Full Snippet Info
5
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: