Before KitKat (or before the new Gallery) the Intent.ACTION_GET_CONTENT
returned a URI like this
content://media/external/images/media/39
Just as Commonsware mentioned, you shouldn't assume, that the stream you get via ContentResolver
is convertable into file.
What you really should do is to open the InputStream
from the ContentProvider
, then create a Bitmap out of it. And it works on 4.4 and earlier versions as well, no need for reflection.
//cxt -> current context
InputStream input;
Bitmap bmp;
try {
input = cxt.getContentResolver().openInputStream(fileUri);
bmp = BitmapFactory.decodeStream(input);
} catch (FileNotFoundException e1) {
}
Of course if you handle big images, you should load them with appropriate inSampleSize
: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html. But that's another topic.