本文整理匯總了Java中android.content.ClipDescription.compareMimeTypes方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipDescription.compareMimeTypes方法的具體用法?Java ClipDescription.compareMimeTypes怎麽用?Java ClipDescription.compareMimeTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.ClipDescription
的用法示例。
在下文中一共展示了ClipDescription.compareMimeTypes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: openTypedAssetFileImpl
import android.content.ClipDescription; //導入方法依賴的package包/類
private final AssetFileDescriptor openTypedAssetFileImpl(
Uri uri, String mimeTypeFilter, Bundle opts, CancellationSignal signal)
throws FileNotFoundException {
enforceTree(uri);
final String documentId = getDocumentId(uri);
if (opts != null && opts.containsKey(ContentResolver.EXTRA_SIZE)) {
final Point sizeHint = opts.getParcelable(ContentResolver.EXTRA_SIZE);
return openDocumentThumbnail(documentId, sizeHint, signal);
}
if ("*/*".equals(mimeTypeFilter)) {
// If they can take anything, the untyped open call is good enough.
return openAssetFile(uri, "r");
}
final String baseType = getType(uri);
if (baseType != null && ClipDescription.compareMimeTypes(baseType, mimeTypeFilter)) {
// Use old untyped open call if this provider has a type for this
// URI and it matches the request.
return openAssetFile(uri, "r");
}
// For any other yet unhandled case, let the provider subclass handle it.
return openTypedDocument(documentId, mimeTypeFilter, opts, signal);
}
示例2: isCommitContentSupported
import android.content.ClipDescription; //導入方法依賴的package包/類
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);
for (String supportedMimeType : supportedMimeTypes) {
if (ClipDescription.compareMimeTypes(mimeType, supportedMimeType)) {
return true;
}
}
return false;
}
示例3: openTypedAssetFile
import android.content.ClipDescription; //導入方法依賴的package包/類
/**
* Copied from super
*/
@Override @TargetApi(19)
public @Nullable AssetFileDescriptor openTypedAssetFile(@NonNull Uri uri, @NonNull String mimeTypeFilter, Bundle opts, CancellationSignal signal) throws FileNotFoundException {
if ("*/*".equals(mimeTypeFilter)) {
// If they can take anything, the untyped open call is good enough.
return openAssetFile(uri, "r", signal);
}
String baseType = getType(uri);
if (baseType != null && ClipDescription.compareMimeTypes(baseType, mimeTypeFilter)) {
// Use old untyped open call if this provider has a type for this
// URI and it matches the request.
return openAssetFile(uri, "r", signal);
}
throw new FileNotFoundException("Can't open " + uri + " as type " + mimeTypeFilter);
}