Weird camera Intent behavior

2019-05-24 09:14发布

I'm invoking the MediaStore.ACTION_IMAGE_CAPTURE intent with the MediaStore.EXTRA_OUTPUT extra so that it does save the image to that file.

On the onActivityResult I can check that the image is being saved in the intended file, which is correct. The weird thing is that anyhow, the image is also saved in a file named something like "/sdcard/Pictures/Camera/1298041488657.jpg" (epoch time in which the image was taken).

I've checked the Camera app source (froyo-release branch) and I'm almost sure that the code path is correct and wouldn't have to save the image, but I'm a noob and I'm not completly sure. AFAIK, the image saving process starts with this callback (comments are mine):

private final class JpegPictureCallback implements PictureCallback {
...
   public void onPictureTaken(...){
       ...
       // This is where the image is passed back to the invoking activity.
       mImageCapture.storeImage(jpegData, camera, mLocation);
       ...

       public void storeImage(final byte[] data,
               android.hardware.Camera camera, Location loc) {
           if (!mIsImageCaptureIntent) {      // Am i an intent?
               int degree = storeImage(data, loc); // THIS SHOULD NOT
BE CALLED WITHIN THE CAPTURE INTENT!!
            .......

      // An finally:
       private int storeImage(byte[] data, Location loc) {
           try {
               long dateTaken = System.currentTimeMillis();
               String title = createName(dateTaken);
               String filename = title + ".jpg";  // Eureka,
timestamp filename!
                ...

So, I'm receiving the correct data, but it's also being saved in the "storeImage(data, loc);" method call, which should not be called...

It'd not be a problem if I could get the newly created filename from the intent result data, but I can't. When I found this out, I found about 20 image files from my tests that I didn't know were on my sdcard :)

I'm getting this behavior both with my Nexus One with Froyo and my Huawei U8110 with Eclair.

Could please anyone enlight me?

Thanks a lot.

0条回答
登录 后发表回答