Barcode

public class Barcode extends Object

Represents a single recognized barcode and its value.

The barcode's raw, unmodified, and uninterpreted content is returned in the getRawValue() field, while the barcode type (i.e. its encoding) can be found in the getFormat() field.

Nested Class Summary

class Barcode.Address An address. 
@interface Barcode.BarcodeFormat Barcode format constants - enumeration of supported barcode formats:
  1. Barcode.FORMAT_UNKNOWN
  2. Barcode.FORMAT_ALL_FORMATS
  3. Barcode.FORMAT_CODE_128
  4. Barcode.FORMAT_CODE_39
  5. Barcode.FORMAT_CODE_93
  6. Barcode.FORMAT_CODABAR
  7. Barcode.FORMAT_DATA_MATRIX
  8. Barcode.FORMAT_EAN_13
  9. Barcode.FORMAT_EAN_8
  10. Barcode.FORMAT_ITF
  11. Barcode.FORMAT_QR_CODE
  12. Barcode.FORMAT_UPC_A
  13. Barcode.FORMAT_UPC_E
  14. Barcode.FORMAT_PDF417
  15. Barcode.FORMAT_AZTEC
 
@interface Barcode.BarcodeValueType Barcode value type constants - enumeration of supported barcode content value types:
  1. Barcode.TYPE_UNKNOWN
  2. Barcode.TYPE_CONTACT_INFO
  3. Barcode.TYPE_EMAIL
  4. Barcode.TYPE_ISBN
  5. Barcode.TYPE_PHONE
  6. Barcode.TYPE_PRODUCT
  7. Barcode.TYPE_SMS
  8. Barcode.TYPE_TEXT
  9. Barcode.TYPE_URL
  10. Barcode.TYPE_WIFI
  11. Barcode.TYPE_GEO
  12. Barcode.TYPE_CALENDAR_EVENT
  13. Barcode.TYPE_DRIVER_LICENSE
 
class Barcode.CalendarDateTime DateTime data type used in calendar events. 
class Barcode.CalendarEvent A calendar event extracted from QRCode. 
class Barcode.ContactInfo A person's or organization's business card. 
class Barcode.DriverLicense A driver license or ID card. 
class Barcode.Email An email message from a 'MAILTO:' or similar QRCode type. 
class Barcode.GeoPoint GPS coordinates from a 'GEO:' or similar QRCode type. 
class Barcode.PersonName A person's name, both formatted version and individual name components. 
class Barcode.Phone Phone number info. 
class Barcode.Sms A sms message from a 'SMS:' or similar QRCode type. 
class Barcode.UrlBookmark A URL and title from a 'MEBKM:' or similar QRCode type. 
class Barcode.WiFi A wifi network parameters from a 'WIFI:' or similar QRCode type. 

Constant Summary

int FORMAT_ALL_FORMATS Barcode format constant representing the union of all supported formats.
int FORMAT_AZTEC Barcode format constant for AZTEC.
int FORMAT_CODABAR Barcode format constant for Codabar.
int FORMAT_CODE_128 Barcode format constant for Code 128.
int FORMAT_CODE_39 Barcode format constant for Code 39.
int FORMAT_CODE_93 Barcode format constant for Code 93.
int FORMAT_DATA_MATRIX Barcode format constant for Data Matrix.
int FORMAT_EAN_13 Barcode format constant for EAN-13.
int FORMAT_EAN_8 Barcode format constant for EAN-8.
int FORMAT_ITF Barcode format constant for ITF (Interleaved Two-of-Five).
int FORMAT_PDF417 Barcode format constant for PDF-417.
int FORMAT_QR_CODE Barcode format constant for QR Code.
int FORMAT_UNKNOWN Barcode format unknown to the current SDK.
int FORMAT_UPC_A Barcode format constant for UPC-A.
int FORMAT_UPC_E Barcode format constant for UPC-E.
int TYPE_CALENDAR_EVENT Barcode value type constant for calendar events.
int TYPE_CONTACT_INFO Barcode value type constant for contact information.
int TYPE_DRIVER_LICENSE Barcode value type constant for driver's license data.
int TYPE_EMAIL Barcode value type constant for email message details.
int TYPE_GEO Barcode value type constant for geographic coordinates.
int TYPE_ISBN Barcode value type constant for ISBNs.
int TYPE_PHONE Barcode value type constant for phone numbers.
int TYPE_PRODUCT Barcode value type constant for product codes.
int TYPE_SMS Barcode value type constant for SMS details.
int TYPE_TEXT Barcode value type constant for plain text.
int TYPE_UNKNOWN Barcode value type unknown, which indicates the current version of SDK cannot recognize the structure of the barcode.
int TYPE_URL Barcode value type constant for URLs/bookmarks.
int TYPE_WIFI Barcode value type constant for WiFi access point details.

Public Method Summary

Rect
getBoundingBox()
Gets the bounding rectangle of the detected barcode.
Barcode.CalendarEvent
getCalendarEvent()
Gets parsed calendar event details.
Barcode.ContactInfo
getContactInfo()
Gets parsed contact details.
Point[]
getCornerPoints()
Returns four corner points in clockwise direction starting with top-left.
String
getDisplayValue()
Returns barcode value in a user-friendly format.
Barcode.DriverLicense
getDriverLicense()
Gets parsed driver license details.
Barcode.Email
getEmail()
Gets parsed email details.
int
getFormat()
Returns barcode format, for example FORMAT_EAN_13.
Barcode.GeoPoint
getGeoPoint()
Gets parsed geo coordinates.
Barcode.Phone
getPhone()
Gets parsed phone number details.
byte[]
getRawBytes()
Returns raw bytes as it was encoded in the barcode.
String
getRawValue()
Returns barcode value as it was encoded in the barcode.
Barcode.Sms
getSms()
Gets parsed SMS details.
Barcode.UrlBookmark
getUrl()
Gets parsed URL bookmark details.
int
getValueType()
Returns format type of the barcode value.
Barcode.WiFi
getWifi()
Gets parsed WiFi AP details.

Inherited Method Summary

Constants

public static final int FORMAT_ALL_FORMATS

Barcode format constant representing the union of all supported formats. This is also the default setting.

Constant Value: 0

public static final int FORMAT_AZTEC

Barcode format constant for AZTEC.

Constant Value: 4096

public static final int FORMAT_CODABAR

Barcode format constant for Codabar.

Constant Value: 8

public static final int FORMAT_CODE_128

Barcode format constant for Code 128.

Constant Value: 1

public static final int FORMAT_CODE_39

Barcode format constant for Code 39.

Constant Value: 2

public static final int FORMAT_CODE_93

Barcode format constant for Code 93.

Constant Value: 4

public static final int FORMAT_DATA_MATRIX

Barcode format constant for Data Matrix.

Constant Value: 16

public static final int FORMAT_EAN_13

Barcode format constant for EAN-13.

Constant Value: 32

public static final int FORMAT_EAN_8

Barcode format constant for EAN-8.

Constant Value: 64

public static final int FORMAT_ITF

Barcode format constant for ITF (Interleaved Two-of-Five).

Constant Value: 128

public static final int FORMAT_PDF417

Barcode format constant for PDF-417.

Constant Value: 2048

public static final int FORMAT_QR_CODE

Barcode format constant for QR Code.

Constant Value: 256

public static final int FORMAT_UNKNOWN

Barcode format unknown to the current SDK.

Constant Value: -1

public static final int FORMAT_UPC_A

Barcode format constant for UPC-A.

Constant Value: 512

public static final int FORMAT_UPC_E

Barcode format constant for UPC-E.

Constant Value: 1024

public static final int TYPE_CALENDAR_EVENT

Barcode value type constant for calendar events. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 11

public static final int TYPE_CONTACT_INFO

Barcode value type constant for contact information. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 1

public static final int TYPE_DRIVER_LICENSE

Barcode value type constant for driver's license data. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 12

public static final int TYPE_EMAIL

Barcode value type constant for email message details. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 2

public static final int TYPE_GEO

Barcode value type constant for geographic coordinates. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 10

public static final int TYPE_ISBN

Barcode value type constant for ISBNs. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 3

public static final int TYPE_PHONE

Barcode value type constant for phone numbers. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 4

public static final int TYPE_PRODUCT

Barcode value type constant for product codes. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 5

public static final int TYPE_SMS

Barcode value type constant for SMS details. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 6

public static final int TYPE_TEXT

Barcode value type constant for plain text. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 7

public static final int TYPE_UNKNOWN

Barcode value type unknown, which indicates the current version of SDK cannot recognize the structure of the barcode. Developers can inspect the raw value instead.

Constant Value: 0

public static final int TYPE_URL

Barcode value type constant for URLs/bookmarks. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 8

public static final int TYPE_WIFI

Barcode value type constant for WiFi access point details. Specifies the format of a Barcode value via the getValueType() field.

Constant Value: 9

Public Methods

public Rect getBoundingBox ()

Gets the bounding rectangle of the detected barcode.

Returns null if the bounding rectangle can not be determined.

public Barcode.CalendarEvent getCalendarEvent ()

Gets parsed calendar event details. This field is set iff getValueType() is TYPE_CALENDAR_EVENT.

public Barcode.ContactInfo getContactInfo ()

Gets parsed contact details. This field is set iff getValueType() is TYPE_CONTACT_INFO.

public Point[] getCornerPoints ()

Returns four corner points in clockwise direction starting with top-left.

Due to the possible perspective distortions, this is not necessarily a rectangle.

Returns null if the corner points can not be determined.

public String getDisplayValue ()

Returns barcode value in a user-friendly format.

This method may omit some of the information encoded in the barcode. For example, if getRawValue() returns 'MEBKM:TITLE:Google;URL://www.google.com;;', the display value might be '//www.google.com'.

This value may be multiline, for example, when line breaks are encoded into the original TEXT barcode value. May include the supplement value.

Returns null if nothing found.

public Barcode.DriverLicense getDriverLicense ()

Gets parsed driver license details. This field is set iff getValueType() is TYPE_DRIVER_LICENSE.

public Barcode.Email getEmail ()

Gets parsed email details. This field is set iff getValueType() is TYPE_EMAIL.

public int getFormat ()

Returns barcode format, for example FORMAT_EAN_13.

public Barcode.GeoPoint getGeoPoint ()

Gets parsed geo coordinates. This field is set iff getValueType() is TYPE_GEO.

public Barcode.Phone getPhone ()

Gets parsed phone number details. This field is set iff getValueType() is TYPE_PHONE.

public byte[] getRawBytes ()

Returns raw bytes as it was encoded in the barcode.

Returns null if the raw bytes can not be determined.

public String getRawValue ()

Returns barcode value as it was encoded in the barcode. Structured values are not parsed, for example: 'MEBKM:TITLE:Google;URL://www.google.com;;'.

It's only available when the barcode is encoded in the UTF-8 format, and for non-UTF8 ones use getRawBytes() instead.

Returns null if the raw value can not be determined.

public Barcode.Sms getSms ()

Gets parsed SMS details. This field is set iff getValueType() is TYPE_SMS.

public Barcode.UrlBookmark getUrl ()

Gets parsed URL bookmark details. This field is set iff getValueType() is TYPE_URL.

public int getValueType ()

Returns format type of the barcode value.

For example, TYPE_TEXT, TYPE_PRODUCT, TYPE_URL, etc.

If the value structure cannot be parsed, TYPE_TEXT will be returned. If the recognized structure type is not defined in your current version of SDK, TYPE_UNKNOWN will be returned.

Note that the built-in parsers only recognize a few popular value structures. For your specific use case, you might want to directly consume getRawValue() and implement your own parsing logic.

public Barcode.WiFi getWifi ()

Gets parsed WiFi AP details. This field is set iff getValueType() is TYPE_WIFI.