当前位置: 首页>>代码示例>>Java>>正文


Java ContentResolver.openFileDescriptor方法代码示例

本文整理汇总了Java中android.content.ContentResolver.openFileDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java ContentResolver.openFileDescriptor方法的具体用法?Java ContentResolver.openFileDescriptor怎么用?Java ContentResolver.openFileDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentResolver的用法示例。


在下文中一共展示了ContentResolver.openFileDescriptor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeBitmap

import android.content.ContentResolver; //导入方法依赖的package包/类
public static Bitmap makeBitmap(int minSideLength, int maxNumOfPixels,
        Uri uri, ContentResolver cr, boolean useNative) {
    ParcelFileDescriptor input = null;
    try {
        input = cr.openFileDescriptor(uri, "r");
        BitmapFactory.Options options = null;
        if (useNative) {
            options = createNativeAllocOptions();
        }
        return makeBitmap(minSideLength, maxNumOfPixels, uri, cr, input,
                options);
    } catch (IOException ex) {
        Log.e(TAG, "", ex);
        return null;
    } finally {
        closeSilently(input);
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:19,代码来源:ThumbnailUtil.java

示例2: handleVideo

import android.content.ContentResolver; //导入方法依赖的package包/类
private void handleVideo(MediaInfo mVideoInfo) {
        mCurrentVideoInfo = mVideoInfo;
        String assetpath = mVideoInfo.getAssetcover();
        File srcFile = new File(assetpath);
        int dotindex = assetpath.lastIndexOf(".");
        if (dotindex != -1) {
            String type = assetpath.substring(dotindex, assetpath.length());
            String compressPath = mSession.getCompressPath();
            if (Build.VERSION.SDK_INT >= 18) {
                FileOutputStream fos = null;
                try {
                    mCacheVideoPath = compressPath + (compressPath.endsWith(File.separator) ? "" : File.separator) + "savorVideo" + type;
                    Uri uriForFile = FileProvider.getUriForFile(this, "com.savor.savorphone.fileprovider", srcFile);
                    ContentResolver contentResolver = getContentResolver();
                    ParcelFileDescriptor pFileDesCripter = contentResolver.openFileDescriptor(uriForFile, "r");
                    FileDescriptor fileDesCripter = pFileDesCripter.getFileDescriptor();
//                    MediaTranscoder.getInstance().transcodeVideo(fileDesCripter, mCacheVideoPath,
//                            MediaFormatStrategyPresets.createExportPreset960x540Strategy(), listener);
                    future = MediaTranscoder.getInstance().transcodeVideo(fileDesCripter, mCacheVideoPath,
                            MediaFormatStrategyPresets.createAndroid720pStrategy(8000 * 1000, 128 * 1000, 1), listener);
                } catch (Exception e) {
                    e.printStackTrace();
                    handleFileCopy(mVideoInfo, srcFile, type, compressPath);
                }
            } else {
                handleFileCopy(mVideoInfo, srcFile, type, compressPath);
            }
        }
    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:30,代码来源:MediaGalleryActivity.java

示例3: mkdir

import android.content.ContentResolver; //导入方法依赖的package包/类
boolean mkdir(final Context context, final File file) throws IOException {
    try {
        if (file.exists()) {
            return file.isDirectory();
        }
        final File tmpFile = new File(file, ".MediaWriteTemp");
        final int albumId = getTemporaryAlbumId(context);
        if (albumId == 0) {
            throw new IOException("Failed to create temporary album id.");
        }
        final Uri albumUri = Uri.parse(String.format(Locale.US, ALBUM_ART_URI + "/%d", albumId));
        final ContentValues values = new ContentValues();
        values.put(MediaStore.MediaColumns.DATA, tmpFile.getAbsolutePath());
        final ContentResolver contentResolver = context.getContentResolver();
        if (contentResolver.update(albumUri, values, null, null) == 0) {
            values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, albumId);
            contentResolver.insert(Uri.parse(ALBUM_ART_URI), values);
        }
        try {
            final ParcelFileDescriptor fd = contentResolver.openFileDescriptor(albumUri, "r");
            if (fd != null)
                fd.close();
        } finally {
            delete(context, tmpFile);
        }
        return file.exists();
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:MediaStoreHack.java

示例4: openDocument

import android.content.ContentResolver; //导入方法依赖的package包/类
@Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
        throws FileNotFoundException {
    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    try {
        final long id = Long.parseLong(docId);
        final ContentResolver resolver = getContext().getContentResolver();
        return resolver.openFileDescriptor(mDm.getUriForDownloadedFile(id), mode);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:14,代码来源:DownloadStorageProvider.java

示例5: initializeOutputStream

import android.content.ContentResolver; //导入方法依赖的package包/类
private void initializeOutputStream() throws FileNotFoundException {
    ContentResolver contentResolver = configuration.getContext().getContentResolver();
    ParcelFileDescriptor outputFileDescriptor = contentResolver.openFileDescriptor(configuration.getUri(), "w");
    backupState.setOutputFileDescriptor(outputFileDescriptor);

    FileOutputStream fileOutputStream = new FileOutputStream(outputFileDescriptor.getFileDescriptor());
    ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
    backupState.setOutputStream(zipOutputStream);
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:10,代码来源:ContentProviderBackupComponent.java

示例6: getArtworkQuick_Base1

import android.content.ContentResolver; //导入方法依赖的package包/类
/**
 * Return album artwork given the id
 * if nothing is found, we try a downloaded one
 *
 * @param context
 * @param album_id
 * @return
 */
public static Bitmap getArtworkQuick_Base1(Context context, long album_id) {
    if (album_id != -1) {
        ContentResolver res = context.getContentResolver();
        Uri uri = ContentUris.withAppendedId(MusicUtils.sArtworkUri, album_id);
        if (uri != null) {
            // ParcelFileDescriptor fd = null;
            try {

                ParcelFileDescriptor fd = res.openFileDescriptor(uri, "r");

                BitmapFactory.Options o2 = new BitmapFactory.Options();

                o2.inSampleSize = 2;
                o2.inDither = false;
                o2.inPreferredConfig = Bitmap.Config.RGB_565;

                Bitmap b = BitmapFactory.decodeFileDescriptor(
                        fd.getFileDescriptor(), null, o2);

                if (b != null) {
                    return b;
                } else {
                    b = getArtworkDownloadedResized(context, album_id);
                    if (b != null) {
                        return b;
                    } else {
                        return null;
                    }
                }
            } catch (FileNotFoundException e) {
                return null;
            }
        }
    }
    return null;
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:45,代码来源:ImageUtils.java

示例7: makeInputStream

import android.content.ContentResolver; //导入方法依赖的package包/类
private static ParcelFileDescriptor makeInputStream(
        Uri uri, ContentResolver cr) {
    try {
        return cr.openFileDescriptor(uri, "r");
    } catch (IOException ex) {
        return null;
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:ThumbnailUtil.java

示例8: buildInputFileDescriptor

import android.content.ContentResolver; //导入方法依赖的package包/类
private ParcelFileDescriptor buildInputFileDescriptor() throws FileNotFoundException {
    ContentResolver contentResolver = configuration.getContext().getContentResolver();
    return contentResolver.openFileDescriptor(configuration.getUri(), "r");
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:5,代码来源:ContentProviderRestoreComponent.java


注:本文中的android.content.ContentResolver.openFileDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。