如何停止MediaStore.ACTION_IMAGE_CAPTURE复制图片 [英] How can I stop MediaStore.ACTION_IMAGE_CAPTURE duplicating pictures
本文介绍了如何停止MediaStore.ACTION_IMAGE_CAPTURE复制图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的code拍摄照片:
I am using the following code to take a picture:
private static final int TAKE_PHOTO_CODE = 1;
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tFile));
startActivityForResult(intent, TAKE_PHOTO_CODE);
这code正常工作,但是我得到的每一张图片我带自动出现在相机镜头的画廊,以及我想要的图片去的副本。
This code works fine however I am getting a copy of every picture I take automatically appearing in the "Camera Shots" gallery as well as where I want the picture to go.
我如何阻止它自动复制我的照片?
How do I stop it automatically copying my picture?
文件名甚至不是同一个我指定的,因此是不喜欢我可以很容易地将其删除。
The file name is not even the same as the one I specified so it is not like I can delete it easily.
感谢您的帮助!
推荐答案
我已经找到了答案。
随着功能删除最后一张照片保存到媒体存储。
Following function delete the last photo saved to media storage.
public void deleteLastCapturedImage() {
String[] projection = {
MediaStore.Images.ImageColumns.SIZE,
MediaStore.Images.ImageColumns.DISPLAY_NAME,
MediaStore.Images.ImageColumns.DATA,
BaseColumns._ID
};
Cursor c = null;
Uri u = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
try {
if (u != null) {
c = managedQuery(u, projection, null, null, null);
}
if ((c != null) && (c.moveToLast())) {
ContentResolver cr = getContentResolver();
int i = cr.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, BaseColumns._ID + "=" + c.getString(c.getColumnIndex(BaseColumns._ID)), null);
Log.v(LOG_TAG, "Number of column deleted : " + i);
}
} finally {
if (c != null) {
c.close();
}
}
}
请在onActivityResult拨打以上功能。
Please call above function within onActivityResult.
这篇关于如何停止MediaStore.ACTION_IMAGE_CAPTURE复制图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文