samples/Support4Demos/src/main/java/com/example/android/supportv4/view/inputmethod/CommitContentSupport.java
private EditText createEditTextWithContentMimeTypes(String[] contentMimeTypes) {
        final CharSequence hintText;
        final String[] mimeTypes;  // our own copy of contentMimeTypes.
        if (contentMimeTypes == null || contentMimeTypes.length == 0) {
            hintText = "MIME: []";
            mimeTypes = new String[0];
        } else {
            hintText = "MIME: " + Arrays.toString(contentMimeTypes);
            mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length);
        }
        EditText exitText = new EditText(this) {
            @Override
            public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
                final InputConnection ic = super.onCreateInputConnection(editorInfo);
                EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
                final InputConnectionCompat.OnCommitContentListener callback =
                        (inputContentInfo, flags, opts) ->
                                CommitContentSupport.this.onCommitContent(
                                        inputContentInfo, flags, mimeTypes);
                return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
            }
        };
        exitText.setHint(hintText);
        exitText.setTextColor(Color.WHITE);
        exitText.setHintTextColor(Color.WHITE);
        return exitText;
    }
/**
     * Creates a new instance of {@link EditText} that is configured to specify the given content
     * MIME types to {@link EditorInfo#contentMimeTypes} so that developers
     * can locally test how the current input method behaves for such content MIME types.
     *
     * @param contentMimeTypes A {@link String} array that indicates the supported content MIME
     *                         types
     * @return a new instance of {@link EditText}, which specifies
     * {@link EditorInfo#contentMimeTypes} with the given content
     * MIME types
     */
Creates a new instance of  EditText that is configured to specify the given content
MIME types to  EditorInfo#contentMimeTypes so that developers
can locally test how the current input method behaves for such content MIME types.

@param contentMimeTypes A  String array that indicates the supported content MIME
types
@return a new instance of  EditText, which specifies
EditorInfo#contentMimeTypes with the given content
MIME types
Creates a new instance of EditText that is configured to specify the given content MIME types to EditorInfo#contentMimeTypes so that developers can locally test how the current input method behaves for such content MIME types . @param contentMimeTypes A String array that indicates the supported content MIME types @return a new instance of EditText which specifies EditorInfo#contentMimeTypes with the given content MIME types
private EditText createEditTextWithContentMimeTypes(String[] contentMimeTypes) {
        final CharSequence hintText;
        final String[] mimeTypes;  
        if (contentMimeTypes == null || contentMimeTypes.length == 0) {
            hintText = "MIME: []";
            mimeTypes = new String[0];
        } else {
            hintText = "MIME: " + Arrays.toString(contentMimeTypes);
            mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length);
        }
        EditText exitText = new EditText(this) {
            @Override
            public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
                final InputConnection ic = super.onCreateInputConnection(editorInfo);
                EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
                final InputConnectionCompat.OnCommitContentListener callback =
                        (inputContentInfo, flags, opts) ->
                                CommitContentSupport.this.onCommitContent(
                                        inputContentInfo, flags, mimeTypes);
                return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
            }
        };
        exitText.setHint(hintText);
        exitText.setTextColor(Color.WHITE);
        exitText.setHintTextColor(Color.WHITE);
        return exitText;
    }
private EditText createEditTextWithContentMimeTypes ( String [ ] contentMimeTypes ) { final CharSequence hintText ; final String [ ] mimeTypes ; if ( contentMimeTypes == null || contentMimeTypes . length == 0 ) { hintText = "MIME: []" ; mimeTypes = new String [ 0 ] ; } else { hintText = "MIME: " + Arrays . toString ( contentMimeTypes ) ; mimeTypes = Arrays . copyOf ( contentMimeTypes , contentMimeTypes . length ) ; } EditText exitText = new EditText ( this ) { @ Override public InputConnection onCreateInputConnection ( EditorInfo editorInfo ) { final InputConnection ic = super . onCreateInputConnection ( editorInfo ) ; EditorInfoCompat . setContentMimeTypes ( editorInfo , mimeTypes ) ; final InputConnectionCompat . OnCommitContentListener callback = ( inputContentInfo , flags , opts ) -> CommitContentSupport . this . onCommitContent ( inputContentInfo , flags , mimeTypes ) ; return InputConnectionCompat . createWrapper ( ic , editorInfo , callback ) ; } } ; exitText . setHint ( hintText ) ; exitText . setTextColor ( Color . WHITE ) ; exitText . setHintTextColor ( Color . WHITE ) ; return exitText ; }
Creates a new instance of {@link EditText} that is configured to specify the given content
 MIME types to {@link EditorInfo#contentMimeTypes} so that developers
 can locally test how the current input method behaves for such content MIME types.
Creates a new instance of { @link EditText } that is configured to specify the given content MIME types to { @link EditorInfo#contentMimeTypes } so that developers can locally test how the current input method behaves for such content MIME types .
// our own copy of contentMimeTypes.