Lo que quiero es que al momento de tomar una foto se me muestre en un imgview pero de otra layout, lo que tengo actualmente es que presiono el botton de la camara me pide permiso para tomar la foto después acepto esa foto y me la muestra en un imgview del la misma layout. Lo que quiero hacer es que una vez tomada la foto y ya haberle dado aceptar a la foto me mande directamente a otro layout con la foto mostrada en una 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);
}
}
Lo puse en un imgview
mSetImage = (ImageView) findViewById(R.id.set_picture);