This is my code:
public class CameraFragment extends Fragment{
String mCurrentPhotoPath = "";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
try {
dispatchTakePictureIntent(); // Here I try to call this method
} catch (IOException dfg) {
Toast.makeText(getContext(), "ERROR!", Toast.LENGTH_LONG).show();
}
//dispatchTakePictureIntent(); //I can't call this like I did here
return inflater.inflate(R.layout.fragment_camera, container, false);
}
ImageView SkimmedImageImg;
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
SkimmedImageImg = (ImageView)view.findViewById(R.id.SkimmedImg);
}
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() throws IOException{
..CODE..
photo = createImageFile();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
..CODE..
}
private File createImageFile() throws IOException{
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DCIM), "Camera");
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
// Save a file: path for use with ACTION_VIEW intents
mCurrentPhotoPath = "file:" + image.getAbsolutePath();
return image;
}
}
How can I fix this problem? I can't remove "throws IOException" from each functions, because I have to call "createImageFile()" and this doesn't works without "throws IOException".
Some ideas? Thank you!