开发者

Prevent image captured via android camera to show up in gallery

开发者_StackOverflow

I'm trying to save the image captured via android camera in a custom location. My code looks like this:

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File f = File(android.os.Environment.getExternalStorageDirectory(), "test.jpg");
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, SUB_ACTIVITY_CAMERA_PREVIEW);

The image is being saved to the desired location but it is also being saved to the default camera folder which is causing it to be displayed in the gallery. Any suggestions?


Include an empty file named .nomedia in your external files directory (note the dot prefix in the filename). This will prevent Android's media scanner from reading your media files and including them in apps like Gallery or Music.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜