android - 如何让 Camera Intent 将照片放入内部存储?

标签 android storage photos

我整天都在做这个,但似乎无法让它工作。根据以前的工作人员的说法,它曾经工作过。

    cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
        String imageName = CustomApp.getTimeStamp(0) ;
        String path = CustomApp.getCurrentActivity().getDir("images", Context.MODE_WORLD_WRITEABLE).getPath()+File.separator+imageName;

        File file = new File(path) ;
        Uri img = Uri.fromFile(file) ;

        Intent passthruDataIntent = new Intent();

        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, img);
        CustomApp.getCurrentActivity().startActivityForResult(cameraIntent, CustomConstants.REQUESTCODE_CAMERA);

类似的代码已发布在此处,但它似乎无法在我的 4.2.2 上的 nexus 4 上运行。我尝试了外部存储,然后它工作正常。任何关于为什么它可能不起作用的见解都会非常有帮助。谢谢。

最佳答案

内部存储对于每个应用都是私有(private)的——第三方相机应用无权写入您的内部存储。

关于android - 如何让 Camera Intent 将照片放入内部存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18024935/

相关文章:

android - 如何使用MediaController.MediaPlayerControl?

java - 从图库或照片中删除图片 android 8.0

ffmpeg - 从图像制作电影的脚本

机器人 : change layout screen in runtime

android - SQLite 数据库和 CursorLoaders

Android 应用程序数据,用户可以访问/编辑吗?

c - 我应该如何在 C 中存储资源

android获取所有设备的所有外部存储路径

ios - 从相机胶卷异步获取所有图像

android - Onclick 监听器无法正常工作..?