createWrapper
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
The view that the given input connection is associated with.
The input connection to be wrapped.
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 to be wrapped
EditorInfo associated with the given inputConnection
the listener that the wrapper object will call
Throws
when inputConnection
, editorInfo
, or onCommitContentListener
is null