question: public static void appendText ( InputConnection connection , String newText ) { if ( connection == null ) { return ; } connection . finishComposingText ( ) ; CharSequence charBeforeCursor = connection . getTextBeforeCursor ( 1 , 0 ) ; if ( charBeforeCursor != null && ! charBeforeCursor . equals ( " " ) && ( charBeforeCursor . length ( ) > 0 ) ) { newText = " " + newText ; } connection . setComposingText ( newText , 1 ) ; }
target:  Append newText to the text field represented by connection. The new text becomes selected.