ContentResolver openFileDescriptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ContentResolver openFileDescriptor method.

This code example shows how to use the following methods:openFileDescriptor
    public static BitmapRegionDecoder requestCreateBitmapRegionDecoder(
            JobContext jc, Uri uri, ContentResolver resolver,
            boolean shareable) {
        ParcelFileDescriptor pfd = null;
        try { 
            pfd = resolver.openFileDescriptor(uri, "r");
            return BitmapRegionDecoder.newInstance(
                    pfd.getFileDescriptor(), shareable);
        } catch (Throwable t) {
            Log.w(TAG, t);
            return null; 
        } finally { 
            Utils.closeSilently(pfd);
        } 
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    } 
 
    private void setupDimension() { 
        ParcelFileDescriptor input = null;
        try { 
            input = mContentResolver.openFileDescriptor(mUri, "r");
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapManager.instance().decodeFileDescriptor( 
                    input.getFileDescriptor(), options);
            mWidth = options.outWidth;
            mHeight = options.outHeight;
        } catch (FileNotFoundException ex) {
            mWidth = 0;
            mHeight = 0;
        } finally { 
            Util.closeSilently(input);
        } 
    } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    public boolean isUriValid() { 
        if (mUri == null) {
            return false; 
        } 
        try { 
            ParcelFileDescriptor pfd =
                    mContentResolver.openFileDescriptor(mUri, "r");
            if (pfd == null) {
                Log.e(TAG, "Fail to open URI.");
                return false; 
            } 
            pfd.close();
        } catch (IOException ex) {
            return false; 
        } 
        return true; 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    public boolean isUriValid() { 
        if (mUri == null) {
            return false; 
        } 
        try { 
            ParcelFileDescriptor pfd =
                    mContentResolver.openFileDescriptor(mUri, "r");
            if (pfd == null) {
                Log.e(TAG, "Fail to open URI.");
                return false; 
            } 
            pfd.close();
        } catch (IOException ex) {
            return false; 
        } 
        return true; 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getCacheDir, getUriForFile
     * channel, since hi-res Bitmaps are too big to serialize into a Bundle. 
     * This file will be passed (as a uri) to other activities (such as the gallery/camera/ 
     *  cropper/etc.), and read by us once they are finished writing it. 
     */ 
    public static Uri generateTempImageUri(Context context) {
        return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY,
                new File(pathForTempPhoto(context, generateTempPhotoFileName())));
    } 
 
    public static Uri generateTempCroppedImageUri(Context context) {
        return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY,
                new File(pathForTempPhoto(context, generateTempCroppedPhotoFileName())));
    } 
 
    private static String pathForTempPhoto(Context context, String fileName) {
        final File dir = context.getCacheDir();
        dir.mkdirs();
        final File f = new File(dir, fileName);
        return f.getAbsolutePath();
    } 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
			return null; 
		} 
 
		ParcelFileDescriptor pfd;
		try { 
		     pfd = resolver.openFileDescriptor(uri, "r");
		} catch (IOException e) {
			Logger.debug(e.getMessage(), e);
		    return null; 
		} 
		 
		java.io.FileDescriptor fd = pfd.getFileDescriptor();
		BitmapFactory.Options options = new BitmapFactory.Options();
 
		//先指定原始大小 
		options.inSampleSize = 1;
		//只进行大小判断 
		options.inJustDecodeBounds = true;
		//调用此方法得到options得到图片的大小 
		BitmapFactory.decodeFileDescriptor(fd, null, options);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    public boolean isUriValid() { 
        if (mUri == null) {
            return false; 
        } 
        try { 
            ParcelFileDescriptor pfd =
                    mContentResolver.openFileDescriptor(mUri, "r");
            if (pfd == null) {
                Log.e(TAG, "Fail to open URI.");
                return false; 
            } 
            pfd.close();
        } catch (IOException ex) {
            return false; 
        } 
        return true; 
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    public boolean isUriValid() { 
        if (mUri == null) {
            return false; 
        } 
        try { 
            ParcelFileDescriptor pfd =
                    mContentResolver.openFileDescriptor(mUri, "r");
            if (pfd == null) {
                Log.e(TAG, "Fail to open URI.");
                return false; 
            } 
            pfd.close();
        } catch (IOException ex) {
            return false; 
        } 
        return true; 
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    } 
 
    private void setupDimension() { 
        ParcelFileDescriptor input = null;
        try { 
            input = mContentResolver.openFileDescriptor(mUri, "r");
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapManager.instance().decodeFileDescriptor( 
                    input.getFileDescriptor(), options);
            mWidth = options.outWidth;
            mHeight = options.outHeight;
        } catch (FileNotFoundException ex) {
            mWidth = 0;
            mHeight = 0;
        } finally { 
            Util.closeSilently(input);
        } 
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:openFileDescriptor
    } 
 
    private void setupDimension() { 
        ParcelFileDescriptor input = null;
        try { 
            input = mContentResolver.openFileDescriptor(mUri, "r");
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapManager.instance().decodeFileDescriptor( 
                    input.getFileDescriptor(), options);
            mWidth = options.outWidth;
            mHeight = options.outHeight;
        } catch (FileNotFoundException ex) {
            mWidth = 0;
            mHeight = 0;
        } finally { 
            Util.closeSilently(input);
        } 
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related ContentResolver openFileDescriptor Questions & Answers:

openFileDescriptor Method Overview
Open a raw file descriptor to access data under a URI.
See Code Examples for other Android ContentResolver Methods: