【发布时间】:2016-11-30 12:25:00
【问题描述】:
我是 android camera API 的新手,代码中有一个 PictureCallback 调用:
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
// Save the image JPEG data to the SD card
FileOutputStream outStream = null;
try {
String path = Environment.getExternalStorageDirectory() +"\test.jpg";
outStream = new FileOutputStream(path);
outStream.write(data);
outStream.close();
} catch (FileNotFoundException e) {
Log.e(TAG, "File Note Found", e);
} catch (IOException e) {
Log.e(TAG, "IO Exception", e);
}
}
};
指出这一行的异常:
outStream = new FileOutputStream(path);
由于我是 Android 世界的新手,所以我不知道这 Environment.getExternalStorageDirectory() 究竟在哪里指出。
异常说:
Java.io.FileNotFoundException:/storage/emulated/0 est.jpg:打开 失败:EACCES(权限被拒绝)
但在我的清单中:
<uses-feature android:name="android.hardware.Camera"/>
<uses-permission android:name="android.permission.CAMERA"/>
编辑:我修复了
的路径String path = Environment.getExternalStorageDirectory() +"/test.jpg";
但还是给了我:
java.io.FileNotFoundException:/storage/emulated/0/test.jpg:打开 失败:EACCES(权限被拒绝)
【问题讨论】: