カメラを閉じてみてください:
@Override
protected void onPause() {
super.onPause();
if (camera != null) {
camera.stopPreview();
camera.release();
camera = null;
}
}
質問
ビルトインカメラアプリを使用して写真を撮って保存しようとしています。 ap [iCtureを使用するだけでも正常に動作します。写真を保存するために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;
}
}