Scan Barcode And qrcode Programmatically In Android Studio


Step 8: Brief Description of ScanActivity.java



Yüklə 139,41 Kb.
səhifə7/7
tarix15.04.2023
ölçüsü139,41 Kb.
#98565
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.
Yüklə 139,41 Kb.

Dostları ilə paylaş:
1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin