private Drawable getDrawable ( Uri uri ) { try { String scheme = uri . getScheme ( ) ; if ( ContentResolver . SCHEME_ANDROID_RESOURCE . equals ( scheme ) ) { // Load drawables through Resources, to get the source density information try { return getDrawableFromResourceUri ( uri ) ; } catch ( Resources . NotFoundException ex ) { throw new FileNotFoundException ( "Resource does not exist: " + uri ) ; } } else { // Let the ContentResolver handle content and file URIs. InputStream stream = mProviderContext . getContentResolver ( ) . openInputStream ( uri ) ; if ( stream == null ) { throw new FileNotFoundException ( "Failed to open " + uri ) ; } try { return Drawable . createFromStream ( stream , null ) ; } finally { try { stream . close ( ) ; } catch ( IOException ex ) { Log . e ( LOG_TAG , "Error closing icon stream for " + uri , ex ) ; } } } } catch ( FileNotFoundException fnfe ) { Log . w ( LOG_TAG , "Icon not found: " + uri + ", " + fnfe . getMessage ( ) ) ; return null ; } }
Gets a drawable by URI without using the cache .