Search code examples
androidandroid-gallerypicasa

Android Nexus 4 give error like java.lang.SecurityException: Permission Deniad


Only issue with Android Nexus 4, OS 4.2

Getting images from Media Gallery using content path give error in only nexus 4.

Content Path like this : content://com.google.android.gallery3d.provider/picasa/item/itemID

Error :

    java.lang.SecurityException: Permission Denial: opening provider
com.android.gallery3d.provider.GalleryProvider from ProcessRecord{658fa748 
4598:com.backlotauctions/u0a739} (pid=4598, uid=10739) requires 
com.google.android.gallery3d.permission.GALLERY_PROVIDER or 
com.google.android.gallery3d.permission.GALLERY_PROVIDER

My Code is:

InputStream is = null;
is = mActivity.getContentResolver().openInputStream(Uri.parse(ImagePath));
OutputStream os = new FileOutputStream(f);
Utils.CopyStream(is, os);
os.close();

This error occurred while content Resolver openInputStream() using image path.


Solution

  • I had the same problem a while ago. see my question here

    Security Exception when trying to access a Picasa image on device running 4.2

    It seems you cannot hold onto the uri of picasa images and just pull the image from the uri everytime, you can only use the uri once.

    basically what I ended up doing was saving the image locally the first time and use that uri for the image