Android - Using Camera Intent but not updating correctly?

Posted by Tyler on Stack Overflow See other posts from Stack Overflow or by Tyler
Published on 2010-05-11T01:38:30Z Indexed on 2010/05/11 1:44 UTC
Read the original article Hit count: 365

Filed under:
|
|
|

Hello -

I am using an intent to capture a picture:

      Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "test.jpg")));
      startActivityForResult(i, 2); 

And then once taken I do the following:

        sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"  + Environment.getExternalStorageDirectory())));
        launchGallery();

While the above seems to work the first time without issue, whenever I run through a second time (so test.jpg already exists) the image actually saves correctly to /sdcard/ but I am finding that the thumbnail does not update and when the gallery loads it shows the previous test.jpg image!

I was under the impression that sendBroadcast should update the thumbnails, but it doesn't appear to be.. Is there some other way to go about this and ensure when I call my launchGallery(); method the most recent image I just took appears?

Thanks!

© Stack Overflow or respective owner

Related posts about android

Related posts about intent