尝试关闭相机:
@Override
protected void onPause() {
super.onPause();
if (camera != null) {
camera.stopPreview();
camera.release();
camera = null;
}
}
题
我正在尝试使用内置相机应用程序拍照并保存。如果只拍摄一张照片,效果很好。当我添加COPDE来保存图片时,从代码退出时,相机应用程序会崩溃
takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
try {
File f = new File(getFilesDir(), "test");
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
} catch (Exception e) {
gi++;
}
startActivityForResult(takePictureIntent, 1);
解决方案
尝试关闭相机:
@Override
protected void onPause() {
super.onPause();
if (camera != null) {
camera.stopPreview();
camera.release();
camera = null;
}
}