Android 相机未保存在特定文件夹中 [MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA]

标签 android android-intent camera image

我在 Intent 中使用 MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA 时遇到问题。相机正常启动,但没有将文件保存在我的特定文件夹“/photo”中。但是当我使用 MediaStore.ACTION_IMAGE_CAPTURE 时它工作正常,但我不能使用它,因为它每次只拍摄一张照片。 我需要相机启动并且用户拍摄很多照片。他关闭相机后,所有照片都保存在我的特定文件夹中。

感谢您的帮助。

问候,

马塞洛

源代码:

public void startCamera() {     
    Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    File file = null;
    try {
        file = createImageFile();
        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    } catch (IOException e) {
        file = null;
        Log.e(this.getClass().getName(), e.getMessage(), e);            
    }
    activity.startActivity(takePictureIntent);
}


private File createImageFile() throws IOException {
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = JPEG_FILE_PREFIX + timeStamp + JPEG_FILE_SUFFIX;
    return new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/photo/", imageFileName);
}

最佳答案

MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA 此 Intent 不支持 Activity 结果或特定 Intent 文件输出。此 Intent 旨在简单地打开相机。您寻求的功能在 Android 中并不存在。

关于Android 相机未保存在特定文件夹中 [MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11637412/

相关文章:

android - Facebook 受众网络竞价整合

android - 如何在 Activity 之间传递 ArrayList<HashMap<String, String>>?

java - 安卓语音识别: startActivityForResult() does not work

c++ - 英特尔实感 3D 相机 (SR300) 的 pmdGet3DCoordinates 相当于什么?

Android 相机 : Difference between PictureCallback, ShutterCallback 和 PreviewCallback

android - 回收站 View 重复背景颜色

android - 如何将 versionCode 转化为 native 代码 (android)

ios - 截图时没有相机 View ,只有白色背景

android - 如何设置 RecyclerView 项目相对于父项的最大高度

android - 注册 Activity 以打开具有特定扩展名的任何文件