title: Using ZXing in a fragment
body: <p>I have searched all over the place and I can't find a working solution on how to implement ZXing in a Fragment. Multiple sources have told me that this is right, but onActivityResult never gets called.</p>
  
  <p>The button click triggers the scanner to open</p>
  
  <pre><code>    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
      view = inflater.inflate(R.layout.fragment_barcode,container,false);
      final Button openBC = (Button)view.findViewById(R.id.btnOpen);
      openBC.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v){
              //This opens up the Barcode Scanner
              IntentIntegrator integrator = new IntentIntegrator(getActivity());
              integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
              integrator.setPrompt("Scan A barcode or QR Code");
              integrator.setCameraId(0);
              integrator.setBeepEnabled(false);
              integrator.setBarcodeImageEnabled(false);
              integrator.initiateScan();
          }
      });
  
  
      return view;
  }
  </code></pre>
  
  <p>This is where the result of the scan should be processed, but it never gets here</p>
  
  <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data) {
      IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
      if(result != null) {
          if(result.getContents() == null) {
              Log.d("MainActivity", "Cancelled scan");
              Toast.makeText(getActivity(), "canceled",Toast.LENGTH_LONG).show();
          } else {
              Log.d("MainActivity", "Scanned");
              Toast.makeText(getActivity(),"Scanned: " + result.getContents(),Toast.LENGTH_LONG).show();
          }
      }else {
          super.onActivityResult(requestCode, resultCode, data);
      }
  }
  </code></pre>