Retrieve a non cached Picasa image from Gallery. 3.0 and 4.0
android, android-3.0-honeycomb, android-4.0-ice-cream-sandwich, gallery, picasa
Solution
The correct solution is to use ACTION_GET_CONTENT. Its name may not sound as intuitive as ACTION_PICK but it's the one you should use for what you are trying to do.
The reason behind using `ACTION_GET_CONTENT` for picking an image in your gallery instead of using `ACTION_PICK` and pointing to the ImageStore's URI provider is that `ACTION_GET_CONTENT` is well supported, whereas `ACTION_PICK` is not. It's been mentioned a couple of times by Android Framework engineers.
I learned it the hard way. Before finding out about this I had to deal with various inconsistencies.
A note related to this
You should always use `openInputStream` to obtain the file through a `ContentResolver` with the `URI` received instead of trying to obtain the real path in which the file is being stored. It may well be the case that the `ContentProvider` implementation is backed by a cloud service (this is the case with Picasa) or the implementation details change over time.
Android's content providers let you abstract how the data is being accessed. Trying to find out where the file is located is a common error I see. Usually what is suggested is to find the location by querying the `DATA` column of the given `URI`. Depending on the `ContentProvider` used it may return different things and even change over time with new versions.
By using `openInputStream` you don't have to care about where the file is, you just receive the stream of bytes and do what you wish with it. This way you won't have problems supporting content providers from other apps like Google Drive, Dropbox, etc that provide a similar picker interface to select an image.
I know OP is using `openInputStream`, but other answers are suggesting otherwise and it's something I see too frequently.
Problem
My app is calling the gallery with an intent that looks like this: ``` Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, SELECT_IMAGE_FROM_GALLERY); ``` In versions < 3.0 there's no problem. With 3.0 and greater versions, when you get a local image, the intent in the onActivityResult method contains an Uri like... ``` content://media/external/images/media/XXX ``` but when you select a picasa image the uri is something like... ``` content://com.google.android.gallery3d.provider/picasa/item/XXXXXXXXXXXXXXXXXXXXX ``` I read many about that problem and I tried many workarounds. At the moment, I can obtain just cached images using: ``` getContentprovider().openInputStream(uri) ``` The problem is that, when the image is not cached, the openInputStream(uri) method, throws a FileNotFoundException, and i can't get the image :_( Anyone knows how to get the file or the url to download the file or something to get the image?? Thanks!!