Monday, 19 August 2013

After take a picture and save it, sometimes the program crash, doesn't return to the activity

After take a picture and save it, sometimes the program crash, doesn't
return to the activity

I'm calling the function dispatchTakePictureIntent to take a picture. But
after take the picture and save it, the application doesn't returns
correctly to the actual activity, the application crash.
when my button is press i call
dispatchTakePictureIntent(1);
then:
public void dispatchTakePictureIntent(int actionCode) {
try {
Intent takePictureIntent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = createImageFile();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(f));
startActivityForResult(takePictureIntent, actionCode);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* Intent takePictureIntent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, actionCode);*/
}
public File createImageFile() throws IOException {
// Create an image file name
final String nomeForm = "teste";
String imageFileName = nomeForm +".jpeg";
File path = getExternalFilesDir(Environment.DIRECTORY_DCIM);
File image = new File(path,imageFileName );
// String getAbsolutePath = image.getAbsolutePath();
Toast.makeText(this, "Image saved to:\n" + image,
Toast.LENGTH_LONG).show();
return image;
}

No comments:

Post a Comment