createWrapper

open fun createWrapper(@NonNull view: View, @NonNull inputConnection: InputConnection, @NonNull editorInfo: EditorInfo): InputConnection(source)

Creates a wrapper InputConnection that implements InputConnection's features on past versions of Android.

Currently, handles commitContent by dispatching to performReceiveContent, enabling apps to use setOnReceiveContentListener to specify handling for content insertion from the IME.

Usage:

public class MyWidget extends View {
    @Override
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
        InputConnection ic = super.onCreateInputConnection(outAttrs);
        if (ic == null) {
            return ic;
        }
        String[] mimeTypes = ViewCompat.getOnReceiveContentMimeTypes(this);
        if (mimeTypes != null) {
            EditorInfoCompat.setContentMimeTypes(outAttrs, mimeTypes);
            ic = InputConnectionCompat.createWrapper(this, ic, outAttrs);
        }
        return ic;
    }
}

Return

A wrapper InputConnection object that can be returned to the IME.

Parameters

view

The view that the given input connection is associated with.

inputConnection

The input connection to be wrapped.

editorInfo

The editor metadata associated with the given input connection.


Deprecated

Use and { } instead.

Creates a wrapper InputConnection object from an existing InputConnection and OnCommitContentListener that can be returned to the system.

By returning the wrapper object to the IME, the editor can be notified by onCommitContent when the IME calls commitContent and the corresponding Framework API that is available on API >= 25.

Return

a wrapper InputConnection object that can be returned to the IME

Parameters

inputConnection

InputConnection to be wrapped

editorInfo

EditorInfo associated with the given inputConnection

onCommitContentListener

the listener that the wrapper object will call

Throws

when inputConnection, editorInfo, or onCommitContentListener is null