Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a Picasa image from URI?

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?

like image 651
Lev Avatar asked Mar 11 '13 03:03

Lev


1 Answers

Try opening input stream like this

ContentResolver res = context.getContentResolver();
Uri uri = Uri.parse(intent.getData().toString());
res.openInputStream(uri);
like image 198
Rifat Döver Avatar answered Sep 29 '22 19:09

Rifat Döver