Code example for ExtractedTextRequest

0
                    "Unable to commit recognition result, as a batch edit cannot start"); 
            return; 
        } 
 
        try { 
            ExtractedTextRequest etr = new ExtractedTextRequest();
            etr.flags = InputConnection.GET_TEXT_WITH_STYLES;
 
            ExtractedText et = conn.getExtractedText(etr, 0);
 
            if (et == null) {
                Log.i(TAG,
                        "Unable to commit recognition result, as extracted text is null"); 
                return; 
            } 
 
            if (et.text != null) {
 
                if (et.selectionStart != et.selectionEnd) {
                    conn.deleteSurroundingText(et.selectionStart,
                            et.selectionEnd);