What I want is that at the moment of taking a picture I am shown in an imgview but from another layout, what I have now is that I press the botton of the camera asks me permission to take the photo after I accept that photo and I the sample in an imgview of the same layout. What I want to do is that once the photo has been taken and I have already given it to accept the photo, send me directly to another layout with the photo shown in an imgview.
private void showOptions() {
final CharSequence[] option = {"Tomar foto", "Cancelar"};
final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Elige una opción");
builder.setItems(option, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(option[which] == "Tomar foto"){
openCamera();
}else if(option[which] == "Elegir de galeria"){
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(intent.createChooser(intent, "Selecciona app de imagen"), SELECT_PICTURE);
}else {
dialog.dismiss();
}
}
});
private void openCamera() {
File file = new File(Environment.getExternalStorageDirectory(), MEDIA_DIRECTORY);
boolean isDirectoryCreated = file.exists();
if(!isDirectoryCreated)
isDirectoryCreated = file.mkdirs();
if(isDirectoryCreated){
Long timestamp = System.currentTimeMillis() / 1000;
String imageName = timestamp.toString() + ".jpg";
mPath = Environment.getExternalStorageDirectory() + File.separator + MEDIA_DIRECTORY
+ File.separator + imageName;
File newFile = new File(mPath);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(newFile));
startActivityForResult(intent, PHOTO_CODE);
}
}
I put it in an imgview
mSetImage = (ImageView) findViewById(R.id.set_picture);