Reputation: 827
When I capture an image, It creates a folder in the gallery and put that image inside that folder. But it takes some time to load (the new folder and the pictures), more or less 1 minute. Why is that? Is there a way to lessen that creation time or just automatically create that folder and put the captured images inside it after taking a photo?
OnClick..
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
Intent intent_cam = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory() + File.separator + "App Photos");
if (!imagesFolder.exists()) {
imagesFolder.mkdirs();
File image = new File(imagesFolder, "App_" + timeStamp + ".png");
Uri uriSavedImage = Uri.fromFile(image);
intent_cam.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
startActivityForResult(intent_cam, 1);
}
else if (imagesFolder.exists()) {
File image = new File(imagesFolder, "App_" + timeStamp + ".png");
Uri uriSavedImage = Uri.fromFile(image);
intent_cam.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
startActivityForResult(intent_cam, 1);
}
Upvotes: 0
Views: 341
Reputation: 1006554
You can use MediaScannerConnection
to have the MediaStore
scan the file. Beyond that, it is up to the implementation of the gallery app, which you do not control.
Upvotes: 1