Scan Barcode And qrcode Programmatically In Android Studio


Step 8: Brief Description of ScanActivity.java


Download 139.41 Kb.
bet7/7
Sana16.04.2023
Hajmi139.41 Kb.
#1358704
1   2   3   4   5   6   7

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.
Download 139.41 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling