mardi 5 mai 2015

How to pass a variable from a AlertDialog to an Activity?

So, I have the following code in my AlertDialog :

  String THISVAR; //Ignore the fact that this is declared here and there is no onCreate
  public Dialog onCreateDialog(Bundle savedInstanceState) {

  AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  builder.setCancelable(true)

          .setItems(R.array.galeria_camera_array, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {

                  if (which == 1) {

                       // My gorgeous code here

                      THISVAR = imageFile.getAbsolutePath();


                  }
              }
          });
  return builder.create();
}

Which then gets opened by the onClick function of an ImageView. Now, my question is, how would I pass the variable THISVAR into another activity? It's the same activity in which I'm opening the dialog, if that matters.

If I wasn't clear enough please DO tell me, I will try to edit this ASAP. Thank you.

Aucun commentaire:

Enregistrer un commentaire