當前位置: 首頁>>代碼示例>>Java>>正文


Java AssetFileDescriptor.UNKNOWN_LENGTH屬性代碼示例

本文整理匯總了Java中android.content.res.AssetFileDescriptor.UNKNOWN_LENGTH屬性的典型用法代碼示例。如果您正苦於以下問題:Java AssetFileDescriptor.UNKNOWN_LENGTH屬性的具體用法?Java AssetFileDescriptor.UNKNOWN_LENGTH怎麽用?Java AssetFileDescriptor.UNKNOWN_LENGTH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.res.AssetFileDescriptor的用法示例。


在下文中一共展示了AssetFileDescriptor.UNKNOWN_LENGTH屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openVideoThumbnailCleared

protected AssetFileDescriptor openVideoThumbnailCleared(long id, CancellationSignal signal)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Thumbnails.EXTERNAL_CONTENT_URI,
                VideoThumbnailQuery.PROJECTION, Video.Thumbnails.VIDEO_ID + "=" + id, null,
                null);
        if (cursor.moveToFirst()) {
            final String data = cursor.getString(VideoThumbnailQuery._DATA);
            return new AssetFileDescriptor(ParcelFileDescriptor.open(
                    new File(data), ParcelFileDescriptor.MODE_READ_ONLY), 0,
                    AssetFileDescriptor.UNKNOWN_LENGTH);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    return null;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:19,代碼來源:StorageProvider.java

示例2: openDocumentThumbnail

@Override
public AssetFileDescriptor openDocumentThumbnail(
        String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException {
    // TODO: extend ExifInterface to support fds
    final ParcelFileDescriptor pfd = openDocument(docId, "r", signal);
    return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:7,代碼來源:AppsProvider.java

示例3: openTypedAssetFile

/**
 * Returns a stream of data for each supported stream type. This method does a query on the
 * incoming URI, then uses
 * {@link android.content.ContentProvider#openPipeHelper(Uri, String, Bundle, Object,
 * PipeDataWriter)} to start another thread in which to convert the data into a stream.
 *
 * @param uri The URI pattern that points to the data stream
 * @param mimeTypeFilter A String containing a MIME type. This method tries to get a stream of
 * data with this MIME type.
 * @param opts Additional options supplied by the caller.  Can be interpreted as
 * desired by the content provider.
 * @return AssetFileDescriptor A handle to the file.
 * @throws FileNotFoundException if there is no file associated with the incoming URI.
 */
@Override
public AssetFileDescriptor openTypedAssetFile(Uri uri, String mimeTypeFilter, Bundle opts)
        throws FileNotFoundException {

    // Checks to see if the MIME type filter matches a supported MIME type.
    String[] mimeTypes = getStreamTypes(uri, mimeTypeFilter);

    // If the MIME type is supported
    if (mimeTypes != null) {

        // Retrieves the note for this URI. Uses the query method defined for this provider,
        // rather than using the database query method.
        Cursor c = query(
                uri,                    // The URI of a note
                READ_NOTE_PROJECTION,   // Gets a projection containing the note's ID, title,
                                        // and contents
                null,                   // No WHERE clause, get all matching records
                null,                   // Since there is no WHERE clause, no selection criteria
                null                    // Use the default sort order (modification date,
                                        // descending
        );


        // If the query fails or the cursor is empty, stop
        if (c == null || !c.moveToFirst()) {

            // If the cursor is empty, simply close the cursor and return
            if (c != null) {
                c.close();
            }

            // If the cursor is null, throw an exception
            throw new FileNotFoundException("Unable to query " + uri);
        }

        // Start a new thread that pipes the stream data back to the caller.
        return new AssetFileDescriptor(
                openPipeHelper(uri, mimeTypes[0], opts, c, this), 0,
                AssetFileDescriptor.UNKNOWN_LENGTH);
    }

    // If the MIME type is not supported, return a read-only handle to the file.
    return super.openTypedAssetFile(uri, mimeTypeFilter, opts);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:58,代碼來源:NotePadProvider.java


注:本文中的android.content.res.AssetFileDescriptor.UNKNOWN_LENGTH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。