title: onActivityResult not called in Fragment only in Activity in scanning appl
body: <p>I am new to Android. My scanning appl is not able to call onActivityResult  in fragment. I did check the other threads but unable to understand the issue.</p>
  
  <pre><code>public class BarCodeFrag extends Fragment {
      // TODO: Rename parameter arguments, choose names that match
      // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
      private static final String ARG_PARAM1 = "param1";
      private static final String ARG_PARAM2 = "param2";
  
      // TODO: Rename and change types of parameters
      private String mParam1;
      private String mParam2;
  
      private OnFragmentInteractionListener mListener;
  
      /**
       * Use this factory method to create a new instance of
       * this fragment using the provided parameters.
       *
       * @param param1 Parameter 1.
       * @param param2 Parameter 2.
       * @return A new instance of fragment SearchCatFragment.
       */
      // TODO: Rename and change types and number of parameters
      public static BarCodeFrag newInstance(String param1, String param2) {
          BarCodeFrag fragment = new BarCodeFrag();
          Bundle args = new Bundle();
          args.putString(ARG_PARAM1, param1);
          args.putString(ARG_PARAM2, param2);
          fragment.setArguments(args);
          return fragment;
      }
  
      public BarCodeFrag() {
          // Required empty public constructor
      }
  
  //    @Override
  //    public void startActivityForResult(Intent intent, int code) {
  //        BarCodeFrag.startActivityForResult(intent, code);
  //    }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              mParam1 = getArguments().getString(ARG_PARAM1);
              mParam2 = getArguments().getString(ARG_PARAM2);
          }
      }
  
      //the custom view
      private SearchView myView;
      private Button scanBtn;
      private TextView formatTxt, contentTxt;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View rootView =  inflater.inflate(R.layout.fragment_barcode, container, false);
  
          //get reference to the custom view
  //        myView = (SearchView) rootView.findViewById(R.id.androidATCView1);
  
          scanBtn = (Button) rootView.findViewById(R.id.scan_button);
          formatTxt = (TextView) rootView.findViewById(R.id.scan_format);
          contentTxt = (TextView) rootView.findViewById(R.id.scan_content);
  
          scanBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  if(v.getId()==R.id.scan_button){
                      //instantiate ZXing integration class
                      IntentIntegrator scanIntegrator = new IntentIntegrator(getActivity());
                      //start scanning
                      scanIntegrator.initiateScan();
                     // startActivityForResult(scanIntegrator, 1888);
  
                  }
                  else{
                      //invalid scan data or scan canceled
                      Toast toast = Toast.makeText(getActivity().getApplicationContext(),
                              "No scan data received!", Toast.LENGTH_SHORT);
                      toast.show();
                  }
              }
          });
          return rootView;
      }
  
      // TODO: Rename method, update argument and hook method into UI event
      public void onButtonPressed(Uri uri) {
          if (mListener != null) {
              mListener.onFragmentInteraction(uri);
          }
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          try {
              mListener = (OnFragmentInteractionListener) activity;
          } catch (ClassCastException e) {
              throw new ClassCastException(activity.toString()
                      + " must implement OnFragmentInteractionListener");
          }
      }
  
      @Override
      public void onDetach() {
          super.onDetach();
          mListener = null;
      }
  
      /**
       * This interface must be implemented by activities that contain this
       * fragment to allow an interaction in this fragment to be communicated
       * to the activity and potentially other fragments contained in that
       * activity.
       * &lt;p/&gt;
       * See the Android Training lesson &lt;a href=
       * "http://developer.android.com/training/basics/fragments/communicating.html"
       * &gt;Communicating with Other Fragments&lt;/a&gt; for more information.
       */
      public interface OnFragmentInteractionListener {
          // TODO: Update argument type and name
          public void onFragmentInteraction(Uri uri);
      }
  
      public void onActivityResult(int requestCode, int resultCode, Intent intent) {
          //retrieve result of scanning - instantiate ZXing object
          super.onActivityResult(requestCode,  resultCode,  intent);
          IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
          //check we have a valid result
  
          Toast.makeText(getActivity().getApplicationContext(), "Inside onActivityResult" , Toast.LENGTH_LONG).show();
  
          if (scanningResult != null) {
              //get content from Intent Result
              String scanContent = scanningResult.getContents();
              //get format name of data scanned
              String scanFormat = scanningResult.getFormatName();
              //output to UI
              formatTxt.setText("FORMAT: " + scanFormat);
              contentTxt.setText("CONTENT: " + scanContent);
  
              Toast.makeText(getActivity().getApplicationContext(), "Reply: " + scanFormat + ":" + scanContent, Toast.LENGTH_LONG).show();
  
              CheckAvailability(scanFormat);
          }}
  </code></pre>
  
  <p>I intend to see FORMAT and CONTENT from scan. This appl is working an an individual appl, but when I add the code in a fragment to add to my other app - I am unable to see FORMAT and CONTENT. Any suggestions are welcome. Many thanks.</p>