android / input-samples

Multiple samples showing the best practices in input on Android.
Apache License 2.0
288 stars 265 forks source link

EditorInfoCompat.getContentMimeTypes(editorInfo); #7

Open WelconeHuang opened 6 years ago

WelconeHuang commented 6 years ago

when running to this method, it always returns an empty array:

private boolean isCommitContentSupported( @Nullable EditorInfo editorInfo, @NonNull String mimeType) { if (editorInfo == null) { return false; }

    final InputConnection ic = getCurrentInputConnection();
    if (ic == null) {
        return false;
    }

    if (!validatePackageName(editorInfo)) {
        return false;
    }

    final String[] supportedMimeTypes = EditorInfoCompat.getContentMimeTypes(editorInfo);// Here is the empty array, and results in false return 

    for (String supportedMimeType : supportedMimeTypes) {
        if (ClipDescription.compareMimeTypes(mimeType, supportedMimeType)) {
            return true;
        }
    }
    return false;
}

I'm running on an Android 8 device