I open the dialog and you can see that I send a call to take a photo or to select it from the gallery. The problem is that once the photo is uploaded the AlertDialog is still open, of course you can add a button like cancel with a simple dismiss
but I need to close it when the activity of gallery or photos is closed. that is ... how can I close the Alertdialog from outside?
private void seleccionarMedio() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Selecciona una foto");
dialog.setMessage("Puedes tomar una foto o cargar una antes previamente tomada");
LayoutInflater inflater = LayoutInflater.from(this);
View login_layout = inflater.inflate(R.layout.vista_foto,null);
LinearLayout Galeria = (LinearLayout)login_layout.findViewById(R.id.botonGaleria);
LinearLayout Tomar = (LinearLayout)login_layout.findViewById(R.id.botonTomar);
dialog.setView(login_layout);
Galeria.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
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);
//Cerrar dialog en esta parte.
}
});
Tomar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openCamera();
}
});
dialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
dialog.show();
}