The HmsScan object is returned by HUAWEI Scan Kit, which contains the coordinates of the barcode in the input image, original data of the barcode, barcode format, structured data, and zoom value.
Call Mode | Return Object | Contained Content | ||||
Default View mode | HmsScan | Original value of a barcode (obtained by getOriginalValue()). | Barcode format (obtained by getScanType()). | Structured data (obtained by getScanTypeForm()). | Barcode position in an image (obtained by getBorderRect()). | |
Customized View mode | HmsScan | Original value of a barcode (obtained by getOriginalValue()). | Barcode format (obtained by getScanType()). | Structured data (obtained by getScanTypeForm()). | Barcode position in an image (obtained by getBorderRect()). | |
BitMap mode | HmsScan | Original value of a barcode (obtained by getOriginalValue()). | Barcode format (obtained by getScanType()). | Structured data (obtained by getScanTypeForm()). | Barcode position in an image (obtained by getBorderRect()). | Zoom ratio (obtained by getZoomValue()). (This item is contained only when Photo mode is set to False.) |
Multiprocessor mode | HmsScan | Original value of a barcode (obtained by getOriginalValue()). | Barcode format (obtained by getScanType()). | Structured data (obtained by getScanTypeForm()). | Barcode position in an image (obtained by getBorderRect()). | |
1. zoomValue: zoom ratio. You need to adjust the camera focal length based on the value. For details, please refer to Scanning Barcodes Using the Camera.
2. Structured data: valid information extracted from 1D and 2D barcodes encoded in a specific format. HUAWEI Scan Kit supports extracting valid information from Wi-Fi, EMAIL, PHONE, ISBN, PRODUCT, SMS, TEXT, URL, CONTACT INFO, GEO, CALENDAR EVENT, and DRIVER LICENSE barcodes, and returns the information to developers. This helps developers quickly build services. For details, please refer to the description of HmsScan.
The following table shows an example of the QR code image.
QR Code | Data Type Returned by Scan Kit | Function for Obtaining the Data | Data Obtained by the App |
| Original value of a barcode | getOriginalValue() | smsto:18300000000:Hello World! |
SMS message information: mobile number | getDestPhoneNumber() | 18300000000 | |
SMS message information: content | getSmsContent() | Hello World! | |
| Original value of a barcode | getOriginalValue() | WIFI:S:WIFI_123;T:WPA;P:12345678;; |
Wi-Fi information: SSID | getSsidNumber() | WIFI_123 | |
Wi-Fi information: password | getPassword() | 12345678 | |
Wi-Fi information: encryption type | getCipherMode() | WPA |
For example, if your app needs to obtain structured data from SMS or Wi-Fi barcode, please refer to the following code:
- public void parseResult(HmsScan result) {
- if (result.getScanTypeForm() == HmsScan.SMS_FORM) {
- HmsScan.SmsContent smsContent = result.getSmsContent();
- String content = smsContent.getMsgContent();
- String phoneNumber = smsContent.getDestPhoneNumber();
- } else if (result.getScanTypeForm() == HmsScan.WIFI_CONNECT_INFO_FORM){
- HmsScan.WiFiConnectionInfo wifiConnectionInfo = result.getWiFiConnectionInfo();
- String password = wifiConnectionInfo.getPassword();
- String ssidNumber = wifiConnectionInfo.getSsidNumber();
- int cipherMode = wifiConnectionInfo.getCipherMode();
- }
- }