当我捕获图像时,它会在图库中创建一个文件夹并将该图像放在该文件夹中。但是加载(新文件夹和图片)需要一些时间,或多或少1分钟。这是为什么?有没有办法减少创建时间或只是自动创建该文件夹并在拍照后将捕获的图像放入其中?
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);
}
答案 0 :(得分:1)
您可以使用MediaScannerConnection
让MediaStore
扫描文件。除此之外,它取决于您无法控制的图库应用程序的实现。