开发者

How do I prevent a duplicate picture from adding to the gallery?

开发者 https://www.devze.com 2023-03-08 23:10 出处:网络
I use the following code to take a picture: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

I use the following code to take a picture:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path + "/" + fileName)));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

Now when I use this, it does save the picture where I specify above, but it also saves a second copy to the default image folder and adds it to the gallery.

I would simply delete the second file, but it seems it would be a tad 开发者_开发百科dangerous as onActivityResult's intent parameter is always null after taking said picture, so I would have to attempt deleting the most recently saved picture.

Is there any way I can prevent this behavior or correct it by getting the URI of the dupicate picture?


Well I've determined that it is pretty much not possible. I am now using a SurfaceView with my own camera activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号