Scan Barcode And qrcode Programmatically In Android Studio


Step 8: Brief Description of ScanActivity.java



Yüklə 139,41 Kb.
səhifə4/7
tarix20.04.2023
ölçüsü139,41 Kb.
#125674
1   2   3   4   5   6   7

Step 8: Brief Description of ScanActivity.java


In onCreate() method, we have set 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(me.dm7.barcodescanner.zbar.Result result) {
// Do something with the result here
Log.v("kkkk", result.getContents()); // Prints scan results
Log.v("uuuu", result.getBarcodeFormat().getName()); // Prints the scan format (qrcode, pdf417 etc.)
MainActivity.tvresult.setText(result.getContents());
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.getContents() method. This method returns the value of barcode in text format.
we have set this barcode text into TextView of MainActivity.
onBackPressed() method will return the user to the Main Activity.
So it was all about scan barcode and QRcode programmatically in android studio example. Thank you 🙂

2. Scan QRCode With ZXing in Android


Hello, developers. In scan barcode and QRcode using zxing Android example, we will learn how to scan the barcode and read QRcode using a zxing library in Android studio.
Barcode or QRCode contains an unique id which is associated with any particular product.
This scanning feature will read that unique id from barcode logo on product box or from the computer screen.
We will use the camera of the android device to scan the barcode.
First of all check output of this scan barcode and QRcode using zxing android tutorial then we will implement it programmatically.
Creating scan barcode and qrcode using zxing android Example

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 ©muhaz.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin