我如何prevent从添加到库中的重复的图片? [英] How do I prevent a duplicate picture from adding to the gallery?

查看:212
本文介绍了我如何prevent从添加到库中的重复的图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code拍摄照片:

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.

我想简单地删除第二个文件,但它似乎的onActivityResult的意图参数始终以表示照片后空那将是一点点危险的,所以我会尝试删除最近保存的图片。

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.

有什么办法,我可以prevent这种行为,或通过获取dupicate图片的URI纠正呢?

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

推荐答案

嗯,我已经决定了它是pretty很多不可能的。我现在用的是SurfaceView用我自己的相机活动。

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

这篇关于我如何prevent从添加到库中的重复的图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆