Step 8: Brief Description of ScanActivity.java
In onCreate() method, we have set the view as scannerview instead of xml file layout.
In onResume() method, we have set the resulthandler and started camera preview.
In onPause() method, we are stopping camera preview.
Step 9: Explaining handleResult() method
@Override
public void handleResult(Result rawResult) {
// Do something with the result here
// Log.v("tag", rawResult.getText()); // Prints scan results
// Log.v("tag", rawResult.getBarcodeFormat().toString()); // Prints the scan format (qrcode, pdf417 etc.)
MainActivity.tvresult.setText(rawResult.getText());
onBackPressed();
// If you would like to resume scanning, call this method below:
//mScannerView.resumeCameraPreview(this);
}
As you can see in above code, we get result object which contains resulting Barcode or QRcode after scanning is completed.
We will get the final result by running result.getText() method and we have set it into TextView of MainActivity.
So it was all about scan barcode and qrcode using zxing android example programmatically.
Use comment section if you find any difficulty while developing this example. You can also share your reviews in the comment section.
Thank you.
Do'stlaringiz bilan baham: |