title: onActivityResult not being trigger from Alert Dialog FIXED
body: <p>Im adding the ability to upload videos in addition to photos in my app. To accomplish this, now when you click the attach button <code>b2</code>instead of the image chooser loading it loads an alert dialog <code>showDialog()</code> to ask which you would like to upload (video or photo) upon selecting, it then loads the image or video selector. Problem is now when you call the method <code>doPositiveClick(Activity activity, int requestCode)</code> from the inner class onActivityResult is not being triggered and no data being returned. I feel that has something to do with it being called from the inner class <code>MyAlertDialogFragment</code> but I'm unsure how to handle it. Thank you.</p>
  
  <pre><code>public static final int REQUEST_CODE = 0, RESULT_PHOTO = 1, RESULT_VID = 2;
  
  
      void showDialog() {
          DialogFragment newFragment = MyAlertDialogFragment.newInstance(
                  R.string.alert_dialog_two_buttons_title);
  newFragment.setTargetFragment(ChatRoomFragment.this, REQUEST_CODE);            
  newFragment.show(getFragmentManager(), "dialog");
  
      }
  
  
  
  
  
    @Override
       if(requestCode == REQUEST_CODE &amp;&amp; data.getData() != null) {
  
          Log.v("response", "Photo Selected");
  
  
                     Uri _uri = data.getData();
                    Log.v("response", "cp1/4");
  </code></pre>
  
  <p>Code is making it to this point^^^^
                        b2.setImageResource(R.drawable.picattached);</p>
  
  <pre><code>if (_uri != null) {
                        //User has pick an image.
                        Cursor cursor = getActivity().getContentResolver().query(_uri, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null);
                        //cursor.moveToFirst();
                        if (cursor == null){
                         uploadMsgPic = _uri.getPath();
                         Log.i("response", "cursor == null");
                         Log.i("response", "uploadMsgPic now = " + uploadMsgPic);
                         }else{
                             Log.i("response", "cursor = "+ cursor);
                         cursor.moveToFirst();
                         Log.v("response", "cp2/4");
                         //Link to the image
                         //cursor.moveToFirst();
                         final String imageFilePath = cursor.getString(0);
                         Log.i("response", "imageFilePath == " + imageFilePath);
                         Log.v("response", "cp3/4");
                         uploadMsgPic = imageFilePath;
                         Log.v("response", "4/4");
                         cursor.close();
                         if (uploadMsgPic == null)
                          uploadMsgPic = _uri.getPath();
                        }
                        Log.i("response", "uploadMsgPic == " + uploadMsgPic);
                        media_attached=true;
  
  
  
                    }
  
                }
             if(requestCode == 6 &amp;&amp; data != null &amp;&amp; data.getData() != null){
                 Uri _uri = data.getData();
                Log.v("response", "cp1/4");
                b2.setImageResource(R.drawable.picattached);
                if (_uri != null) {
                    //User has pick an image.
                    Cursor cursor = getActivity().getContentResolver().query(_uri, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null);
                    //cursor.moveToFirst();
                    if (cursor == null){
                     uploadMsgPic = _uri.getPath();
                     Log.i("response", "cursor == null");
                     Log.i("response", "uploadMsgPic now = " + uploadMsgPic);
                     }else{
                         Log.i("response", "cursor = "+ cursor);
                     cursor.moveToFirst();
                     Log.v("response", "cp2/4");
                     //Link to the image
                     //cursor.moveToFirst();
                     final String imageFilePath = cursor.getString(0);
                     Log.i("response", "imageFilePath == " + imageFilePath);
                     Log.v("response", "cp3/4");
                     uploadMsgPic = imageFilePath;
                     Log.v("response", "4/4");
                     cursor.close();
                     if (uploadMsgPic == null)
                      uploadMsgPic = _uri.getPath();
                    }
                    Log.i("response", "uploadMsgPic == " + uploadMsgPic);
                    media_attached=true;
  
                }
  
            }
  
             super.onActivityResult(requestCode, resultCode, data); 
      }
  
  
  //Generics:
  //1. Long: Type of reference(s) passed to doInBackground()
  //2. String: Type of reference passed to onProgressUpdate()
  //3. STRING: Type of reference returned by doInBackground()
  //Value passed to onPostExecute()
  
  
  
  
  
      public static void doPositiveClick(Activity activity, int requestCode) {
          Log.i("ChatRoomFragMent", "doPositive Clicked");
          Intent intent = new Intent();
          intent.setType("image/*");
          intent.setAction(Intent.ACTION_GET_CONTENT);
          activity.startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_CODE);
  
  
  
          // Do stuff here.
          Log.i("ChatRoomFragMent", "picture selector loaded");
      }
  
      public void doNegativeClick() {
  
          Intent intent = new Intent();
          intent.setType("video/*");
          intent.setAction(Intent.ACTION_GET_CONTENT);
          startActivityForResult(Intent.createChooser(intent, "Select Video"), RESULT_VID);
  
  
          // Do stuff here.
          Log.i("FragmentAlertDialog", "Negative click!");
      }
  
      public static class MyAlertDialogFragment extends SherlockDialogFragment {
  
          public static MyAlertDialogFragment newInstance(int title) {
              MyAlertDialogFragment frag = new MyAlertDialogFragment();
              Bundle args = new Bundle();
              args.putInt("title", title);
              frag.setArguments(args);
              return frag;
          }
  
  
          @Override
          public Dialog onCreateDialog(Bundle savedInstanceState) {
              int title = getArguments().getInt("title");
             return new AlertDialog.Builder(getActivity())
                      //.setIcon(R.drawable.alert_dialog_icon)
                      .setTitle(title)
                      .setPositiveButton("Photo",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int whichButton) {  Intent data = new Intent();
  
                              //((FragmentAlertDialogSupport)getActivity()).doPositiveClick();
                              ChatRoomFragment.doPositiveClick(getActivity(), 5);
                              getTargetFragment().onActivityResult(getTargetRequestCode(), RESULT_PHOTO, data);
                           }
                          }
                      )
                      .setNegativeButton("Video",
                          new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int whichButton) {
                                  //((FragmentAlertDialogSupport)getActivity()).doNegativeClick();
                                  //doNegativeClick();
                              }
                          }
                      )
                      .create();
          }
      }
  }
  </code></pre>