title: intermittent QR Scan results using ZXing IntentIntegrator
body: <p>I tried my best to find the solution before asking, however, I can't seem to locate a similar situation.</p>
  
  <p>I've implemented a QR scanner for an app I am working on. I'm using the zxing library, specifically using the imports below. Also, the apps uses "Barcode Scanner" from play store (I was prompted to install).</p>
  
  <pre><code>import com.google.zxing.integration.android.IntentIntegrator;
  import com.google.zxing.integration.android.IntentResult;
  </code></pre>
  
  <p>The issue is that the scanner only works 1 out every 3-6 scans. I either get a null return, or no output. It always returns back to my source screen, and never produces an actual error.</p>
  
  <p>I used this tutorial as a source: <a href="http://code.tutsplus.com/tutorials/android-sdk-create-a-barcode-reader--mobile-17162" rel="nofollow">Android SDK: Create a Barcode Reader</a></p>
  
  <p>Here is the relevant info from mainactivity:</p>
  
  <pre><code>    public void onClick(View v){
              //respond to clicks
              if(v.getId()==R.id.scanQRButton){
                  //scan
                  IntentIntegrator scanIntegrator = new IntentIntegrator(this);
                  scanIntegrator.initiateScan();
                  formatTxt.setText( "Scan Initiated");
                  contentTxt.setText(" Scan Results: " + scanContent);
  
                  if(scanContent != null){
  
                      String userid,medname,tabstaken,dob;
  
  
                      StringTokenizer st = new StringTokenizer(scanContent, ",");
                           // token 0
                           dob = st.nextToken();
                           //token 1
                           medname = st.nextToken();
                           //token 2
                           tabstaken = st.nextToken();
                           //token 3
                           //rxnumber
  
                      DatabaseHandler db = new DatabaseHandler(getApplicationContext());
  
                      HashMap&lt;String,String&gt; user = new HashMap&lt;String, String&gt;();
                      user = db.getUserDetails();
  
                      //Store the userlog by passing to UserLogEntry
                      userid = user.get("uid");
                      //debug.setText("Userid: "+ userid+ " medname: " + medname + " tabs: " +tabstaken);
  
                      UserLogEntry userlog = new UserLogEntry(getApplicationContext(),userid,medname,tabstaken);
                      userlog.addUserLog();
  
  
  
                  }
  
  
  
              }
  
          }
  
      public void onActivityResult(int requestCode, int resultCode, Intent intent) {
          //retrieve scan result
          IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
  
          if (scanningResult != null) {
              //we have a result
              scanContent = scanningResult.getContents();
  
  
  
          }
          else{
              Toast toast = Toast.makeText(getApplicationContext(), 
                  "No scan data received!", Toast.LENGTH_SHORT);
              toast.show();
          }
      }
  
  
  }
  </code></pre>
  
  <p>And here are the ZXing classes from the library package I'm using:</p>
  
  <p>IntentResults:</p>
  
  <p><a href="https://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java?r=1273" rel="nofollow">https://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java?r=1273</a></p>
  
  <p>IntentIntegrator:</p>
  
  <p><a href="https://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java?spec=svn2260&amp;r=2260" rel="nofollow">https://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java?spec=svn2260&amp;r=2260</a></p>
  
  <p>Any ideas on how to get this to work %100 of the time? </p>
  
  <p>Thanks!</p>