8

我在使用相机的 android 开发人员的资源时遇到问题,这是我的代码:

// create Intent to take a picture and return control to the calling application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

// create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

问题是“MEDIA_TYPE_IMAGE”,它表示它无法解析为变量。我将媒体商店、相机和 URI 导入到我的项目中。提前致谢!

4

4 回答 4

16

尝试导入android.provider.MediaStore.Files.FileColumns并更改MEDIA_TYPE_IMAGEFileColumns.MEDIA_TYPE_IMAGE.

如果您使用的是来自 Android 开发者博客的示例代码,请务必查看关于保存媒体文件的部分,您已经创建了用于处理该问题的常量。

于 2012-08-01T20:21:35.927 回答
5

问题:MEDIA_TYPE_IMAGE 无法识别

Anwser:请在您的班级中添加行

public static final int MEDIA_TYPE_IMAGE = 1;
于 2012-11-16T01:26:52.077 回答
2

如果您正在尝试 android 指南中的相机示例,请阅读此
http://developer.android.com/guide/topics/media/camera.html#saving-media 他们已在文档底部声明了该方法

于 2014-06-27T08:39:54.927 回答
0

可能是您没有在清单中授予良好的权限(例如相机访问权限、外部存储访问权限等)

于 2012-06-05T17:21:11.100 回答