试图保存相机拍摄的照片,但应用程序崩溃

时间:2013-11-07 21:13:49

标签: android android-camera-intent

我正在尝试使用内置的相机应用来拍照并保存。如果它只需要一个p [图片]它工作正常。当我添加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);

1 个答案:

答案 0 :(得分:0)

尝试关闭相机:

@Override
      protected void onPause() {
      super.onPause();
        if (camera != null) {
            camera.stopPreview();
            camera.release();
            camera = null;
    }
}
相关问题