Android Zxing Barcode Scanner is not scanning correctly
<p>In my <code>Android application</code>, I am having <code>Barcode</code> scanning functionality. For this functionality I am using Android <a href="https://github.com/dm77/barcodescanner" rel="nofollow">https://github.com/dm77/barcodescanner</a> library for scanning <code>Barcodes</code>. It is working good, But if I scanned repeatedly in my project, sometimes it is returning a <code>wrong value(not the actual value)</code> of the barcode.I would like to know why it is happening and how to resolve this issue. I have googled but unfortunately I didn't find any better solution.Anyone please guide me to fix the issue.</p>

<p><strong>note:</strong> I am using latest version 1.8.4</p>

<p><strong>SimpleScannerActivity.java</strong></p>

<pre><code>import com.google.zxing.Result;

import me.dm7.barcodescanner.core.IViewFinder;
import me.dm7.barcodescanner.core.ViewFinderView;
import me.dm7.barcodescanner.zxing.ZXingScannerView;

    public class SimpleScannerActivity extends BaseScannerActivity implements ZXingScannerView.ResultHandler {
        private ZXingScannerView mScannerView;

        LoadingFlowScreen loadingFlowScreen;
        NextScanScreen nextScanScreen;

        String shipmentin,locationin;


        @Override
        public void onCreate(Bundle state) {
            super.onCreate(state);
            setContentView(R.layout.activity_simple_scanner);
            setupToolbar();

            loadingFlowScreen = new LoadingFlowScreen();
            nextScanScreen = new NextScanScreen();



            ViewGroup contentFrame = (ViewGroup) findViewById(R.id.content_frame);
            mScannerView = new ZXingScannerView(this) {
                @Override
                protected IViewFinder createViewFinderView(Context context) {
                    return new CustomViewFinderView(context);
                }
            };
            contentFrame.addView(mScannerView);
        }

        @Override
        public void onResume() {
            super.onResume();
            mScannerView.setResultHandler(this);
            mScannerView.startCamera();
        }

        @Override
        public void onPause() {
            super.onPause();
            mScannerView.stopCamera();
        }

        @Override
        public void handleResult(Result rawResult) {


            Intent in = new Intent(SimpleScannerActivity.this, NextScreen.class);//forwaring to another activity once scanned the barcode
            in.putExtra("scannedText",rawResult.getText());//storing the value in prefernce
            startActivity(in);
            finish();            

          mScannerView.resumeCameraPreview(SimpleScannerActivity.this);

        }

        private static class CustomViewFinderView extends ViewFinderView {
            public static final String TRADE_MARK_TEXT = "";
            public static final int TRADE_MARK_TEXT_SIZE_SP = 40;
            public final Paint PAINT = new Paint();

            public CustomViewFinderView(Context context) {
                super(context);
                init();
            }

            public CustomViewFinderView(Context context, AttributeSet attrs) {
                super(context, attrs);
                init();
            }

            private void init() {
                PAINT.setColor(Color.WHITE);
                PAINT.setAntiAlias(true);
                float textPixelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
                        TRADE_MARK_TEXT_SIZE_SP, getResources().getDisplayMetrics());
                PAINT.setTextSize(textPixelSize);
            }

            @Override
            public void onDraw(Canvas canvas) {
                super.onDraw(canvas);
                drawTradeMark(canvas);
            }

            private void drawTradeMark(Canvas canvas) {
                Rect framingRect = getFramingRect();
                float tradeMarkTop;
                float tradeMarkLeft;
                if (framingRect != null) {
                    tradeMarkTop = framingRect.bottom + PAINT.getTextSize() + 10;
                    tradeMarkLeft = framingRect.left;
                } else {
                    tradeMarkTop = 10;
                    tradeMarkLeft = canvas.getHeight() - PAINT.getTextSize() - 10;
                }
                canvas.drawText(TRADE_MARK_TEXT, tradeMarkLeft, tradeMarkTop, PAINT);
            }
        }
    }
</code></pre>

<p><strong>BaseScannerActivity.java</strong></p>

<pre><code>public class BaseScannerActivity extends AppCompatActivity {
    public void setupToolbar() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        final ActionBar ab = getSupportActionBar();
        if(ab != null) {
            ab.setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // Respond to the action bar's Up/Home button
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
</code></pre>