Picasa Images From Gallery

All your problems with Audio, Video and Images.

Picasa Images From Gallery

Postby hallow » Mon Oct 24, 2011 6:19 pm

I want to allow users to select an image from the gallery, and attach that image to some content inside my application. This code basically does the trick:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         Intent intent = new Intent(Intent.ACTION_PICK);
  2.         intent.setType("image/*");
  3.         intent.putExtra("return-data", true);
  4.         startActivityForResult(
  5.                 Intent.createChooser(
  6.                         intent,
  7.                         "Complete action using"
  8.                 ),
  9.                 PICK_FROM_GALLERY
  10.         );
Parsed in 0.043 seconds, using GeSHi

Now, once this runs, I want to get the thumbnail.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  3.         if (resultCode != Activity.RESULT_OK)
  4.                 return;
  6.         Uri contentUri = Uri.parse(data.getDataString());
  7.         List<String> parts = contentUri.getPathSegments();
  8.         long id = Long.parseLong(parts.get(parts.size() - 1));
  9.         Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(
  10.                 getActivity().getContentResolver(),
  11.                 id,
  12.                 MediaStore.Images.Thumbnails.MINI_KIND,
  13.                 null
  14.         );
  16. }
Parsed in 0.032 seconds, using GeSHi

This works well, unless I choose an image from the gallery that comes from picasa (this is on Honeycomb, BTW). If I pick an image from picasa, I get:

For my URI:

For my ID:

bitmap winds up being null, and I get this exception:
E/MiniThumbFile(26253): Got exception when reading magic, id = SOMEBIGNUMBER, disk full or mount read-only? class java.lang.IllegalArgumentException

For images that work, I get a URI like this:

I can inspect the URI, and if it's picasa, show a Toast or something that picasa images cannot be attached -- but that's not ideal. Is there someway, using the gallery, to get the thumbnail, and eventually the big picture from picasa, or am I stuck here without going out to picasa directly within my app? Or is it possible somehow to disable showing the picasa images in the gallery when doing the ACTION_PICK (like how videos don't show up now)?
Once Poster
Once Poster
Posts: 1
Joined: Tue Apr 07, 2009 9:14 pm


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 15 guests