Sunday, October 7, 2018

Barcode Scan in Android

1. First Add this in yr Gradle


compile 'me.dm7.barcodescanner:zxing:1.9.8'
compile 'com.edwardvanraak:MaterialBarcodeScanner:0.0.6-ALPHA'

2.Secondly Add this in Activity


public static final String BARCODE_KEY = "BARCODE";

private Barcode barcodeResult;

Use This Method 


private void startScan() {
final MaterialBarcodeScanner materialBarcodeScanner = new MaterialBarcodeScannerBuilder()
            .withActivity(this)
            .withEnableAutoFocus(true)
            .withBleepEnabled(true)
            .withBackfacingCamera()
            .withCenterTracker()
            .withText("Scanning...")
            .withResultListener(new MaterialBarcodeScanner.OnResultListener() {
                @Override                public void onResult(Barcode barcode) {
                    barcodeResult = barcode;
                                                   
                    String Get_code_Text = barcode.rawValue.toString();
                   

                }
            })
            .build();
    materialBarcodeScanner.startScan();
}





No comments:

Post a Comment