Code example for InputConnection

Methods: getTextBeforeCursor

0
 
    public static CharSequence getPreviousWord(InputConnection connection,
            String sentenceSeperators) {
        //TODO: Should fix this. This could be slow! 
        if (null == connection) return null;
        CharSequence prev = connection.getTextBeforeCursor(LOOKBACK_CHARACTER_NUM, 0);
        return getPreviousWord(prev, sentenceSeperators);
    } 
 
    // Get the word before the whitespace preceding the non-whitespace preceding the cursor. 
    // Also, it won't return words that end in a separator. 
    // Example : 
    // "abc def|" -> abc 
    // "abc def |" -> abc 
    // "abc def. |" -> abc 
    // "abc def . |" -> def 
    // "abc|" -> null 
    // "abc |" -> null 
    // "abc. def|" -> null 
    public static CharSequence getPreviousWord(CharSequence prev, String sentenceSeperators) {
        if (prev == null) return null;