Class BarcodeResult


  • public class BarcodeResult
    extends Object
    This helper class can be constructed from an Intent received by a broadcast receiver that is registered for INTENT_ACTION. Once constructed methods in this class are used to obtain information about the barcode tha was scanned.

     public void onStart() {
         IntentFilter filter = new IntentFilter(BarcodeResult.INTENT_ACTION);
         registerReceiver(mBarcodeReceiver, filter);
     }
    
     private final BroadcastReceiver mBarcodeReceiver = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
             BarcodeResult br = new BarcodeResult(intent);
             Log.d(TAG, "Received scan with result" + br.getBarcode());
         }
     };
    
     public void onStop() {
         unregisterReceiver(mBarcodeReceiver);
     }
     
    • Field Detail

      • INTENT_ACTION

        public static final String INTENT_ACTION
        Broadcast Action: Sent by Clover when a barcode is scanned.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BarcodeResult

        public BarcodeResult​(Intent intent)
        Constructs an instance of this class from an Intent received with the action INTENT_ACTION.
    • Method Detail

      • isBarcodeAction

        public boolean isBarcodeAction()
        True unless the Intent provided does not have the action INTENT_ACTION. When used properly calling this method isn't necessary.
      • getBarcode

        public String getBarcode()
        Returns the data encoded by the barcode as a String.
      • getType

        public String getType()
        Returns a String that describes the type of barcode. Returns "usb" for barcodes scanned by USB barcode scanners since the actual type is unknown.
      • isQRCode

        public boolean isQRCode()
        True if this is a QR code, false if not or if scanner is USB barcode scanner.
      • isCode128

        public boolean isCode128()
        True if this is a code 128, false if not or if scanner is USB barcode scanner.
      • isUPCA

        public boolean isUPCA()
        True if this is a UPCA, false if not or if scanner is USB barcode scanner.
      • isUPCE

        public boolean isUPCE()
        True if this is a UPCE, false if not or if scanner is USB barcode scanner.
      • isUSB

        public boolean isUSB()
        Returns true if the Barcode originated from an external USB barcode scanner. Barcodes from such scanners will not have a type and all the standard
        is
        methods will return false.
      • isQRCodeOrUSB

        public boolean isQRCodeOrUSB()
        Returns true if isQRCode() is true or scanner is a USB barcode scanner.
      • isCode128OrUSB

        public boolean isCode128OrUSB()
        Returns true if isCode128() is true or scanner is a USB barcode scanner.
      • isUPCAOrUSB

        public boolean isUPCAOrUSB()
        Returns true if isUPCA() is true or scanner is a USB barcode scanner.
      • isUPCEOrUSB

        public boolean isUPCEOrUSB()
        Returns true if isUPCE() is true or scanner is a USB barcode scanner.