I have a fragment which shows a list of taken pictures, and allows me to take a new one by clicking a button; however, after taken a picture it goes to a PreviewActivity to accept or cancel the picture taken, and also add a description.
After that, I want to comeback to the fragment with the information. To clarify:
My fragment calls the cameras as below:
imgCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
nameFile = UUID.randomUUID().toString().replaceAll("-", "");
fileName = HelperFoto.createFile(HelperFoto.getTempFile() + date.replace(":", "_"), nameFile + ".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(fileName.toString())));
startActivityForResult(intent, 2);
}
});
After that, I send the generated data to the PreviewActivity as below:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 2 && resultCode == Activity.RESULT_OK) {
Intent startPreview = new Intent(getContext(), PreviewActivity.class);
startPreview.putExtra("path", fileName.toString());
startActivity(startPreview);
}
super.onActivityResult(requestCode, resultCode, data);
}
Therefore, in my PreviewActivity, I was able to retrieve all the necessary information; thus, I can't send it back to the fragment (I tried to use onBackPressed() without success).
Could someone help me?