【发布时间】:2014-07-14 12:09:12
【问题描述】:
我正在使用Camera Intent 和以下代码
public void clickPicturesThroughCamera() {
try {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
initImageUri();
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, RETURN_FROM_CAMERA);
} catch (Exception e) {
showToast(getString(R.string.error_opening_camera));
}
}
public void initImageUri() {
ContentValues cv = new ContentValues();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat,
Locale.ENGLISH);
String name =simpleDateFormat.format(Calendar.getInstance().getTime())
+ "_" + new Random().nextInt(100) + ".jpg";
cv.put(MediaStore.Images.Media.TITLE, name);
imageUri = getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv);
}
捕获的图像将存储在/storage/sdcard0/DCIM/Camera/imagename.jpg。但是当我通过默认的相机应用程序单击图像时,它将存储在storage/extSdCard/DCIM/Camera/imagename.jpg,因为我默认使用外部 sdcard 来存储捕获的图像。
所以我的主要要求是我正在开发的应用程序应该将捕获的图像存储在默认位置,即storage/extSdCard/DCIM/Camera/imagename.jpg而不是/storage/sdcard0/DCIM/Camera/imagename.jpg。为此,我应该在上面的代码中做什么,以便它始终将图像保存在默认的 Camera 文件夹中。
谢谢
【问题讨论】:
标签: android android-camera-intent