尝试拍照并且在权限方面给我一个错误。因为它无法保存。
<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并出现同样的错误; /
答案 0 :(得分:2)
权限名称区分大小写。使用:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>