Question

I'm trying to use the built in camera app to take a picture and save it. It works fine if it just takes a p[icture. When I add the copde to save the pictures, the camera app crashes when I exit from it code

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);
Was it helpful?

Solution

Try closing camera:

@Override
      protected void onPause() {
      super.onPause();
        if (camera != null) {
            camera.stopPreview();
            camera.release();
            camera = null;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top