12

I'm using ACTION_PICK intent to select an image from gallery. Some albums like "Posts", "Profile Photos", etc are marked with Picasa icon. For images from such albums I get a URI similar to this:

content://com.google.android.gallery3d.provider/picasa/item/5769844615871490082

I can load an image from this URI using ContentResolver and BitmapFactory with no problem:

final InputStream ist = context.getContentResolver().openInputStream(intent.getData());
final Bitmap bitmap = BitmapFactory.decodeStream(ist);

But I'm unable to load an image using stored URI after I restart the application. I'm getting this when decodeStream() is called:

03-11 12:34:56.502: A/libc(1172): Fatal signal 11 (SIGSEGV) at 0x00000408 (code=1), thread 1462 03-11 12:34:56.502:
    W/ActivityManager(478): Permission Denial: opening provider
    com.android.gallery3d.provider.GalleryProvider from
    ProcessRecord{41cdd220 1172:com.mycompany.myapp/u0a10085}
    (pid=1172, uid=10085) requires
    com.google.android.gallery3d.permission.GALLERY_PROVIDER or
    com.google.android.gallery3d.permission.GALLERY_PROVIDER

I tried to add

<uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER"/>

to the manifest file but it didn't help.

I think my problem is similar to this one, but no solution is given there, only a workaround. Is it possible to request a permission to access a stored URI?

Community
  • 1
  • 1
Lev
  • 730
  • 12
  • 32
  • 2
    The content-URIs are most likely time-limited, and only work in the context of the ACTION_PICK. You'll need to cache the image in your app, as there's no guarantee that the content is even available later on. – 323go Mar 11 '13 at 03:21
  • i swear im gona run into the same problem, favorite again – JRowan Mar 11 '13 at 03:27
  • Did you find a solution for this? I am facing the same problem. – Archie.bpgc Sep 19 '13 at 06:43
  • I open image data as a stream and save it into a local file. See suggested solution below. – Lev Sep 22 '13 at 23:08

1 Answers1

4

Try opening input stream like this

ContentResolver res = context.getContentResolver();
Uri uri = Uri.parse(intent.getData().toString());
res.openInputStream(uri);
Rifat Döver
  • 494
  • 4
  • 17