【发布时间】:2014-09-14 09:07:14
【问题描述】:
试图拍照,但它给了我权限错误。因为它无法保存。
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.write_external_storage"/>
private PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Log.d(TAGL,"W onPictureTaken");
File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
if (pictureFile == null){
Log.d(TAGL, "Error creating media file, check storage permissions: ");
//It shows the error I do not have Permission.
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
Log.d(TAGL, "File not found: " + e.getMessage());
} catch (IOException e) {
Log.d(TAGL, "Error accessing file: " + e.getMessage());
}
}
};
为什么我会拒绝访问? 在 Android 设备 4.04 和 4,4,2 上测试,同样的错误; /
【问题讨论】:
-
如果您在模拟器中使用它,请检查内部或外部 sd 卡的大小或增加 sd 卡的大小以便您可以在其中存储图像。这可能是由于空间较小,不允许存储图像.
-
有 4gb 免费,我没有使用模拟器
-
Log > 334-334/com.example.ciacho.kamdostep D/MyAcitvity:创建媒体文件时出错,请检查存储权限:
标签: android permissions camera