SUNMI Scanning SDK
SUNMI Scanning SDK
3. Easy to use. With five lines of code, you are able to add scan function in your
project.
4. Support scanning 17 types of codes, and more code types will be added later.
5. Perfectly fitted to SUNMI’s devices. The combination of hardware and
software ensures highly efficiency and stability.
1. Use your App to call the barcode scanning module integrated by SUNMI’s UI
system for scanning, and get return values. This method is very easy to use.
2. Write your own camera interface and call the scanning SDK encapsulated by
SUNMI to parse images. This method is relatively complicated but provides
higher degrees of freedom.
Create an Intent where you want to start scanning; Call the scanning module by
startActiityForResult().
*/
intent.setPackage("com.sunmi.sunmiqrcodescanner")
/*
intent.setClassName("com.sunmi.sunmiqrcodescanner",
"com.sunmi.sunmiqrcodescanner.activity.ScanActivity");
//PPI_1920_1080 = 0X0001;
//PPI_1280_720 = 0X0002;
//PPI_BEST = 0X0003;
startActivityForResult(intent, START_SCAN);
Receive the return parameters of the scan results by onActivityResult. You can refer
to the following code:
@Override
Iterator<> it = result.iterator();
while (it.hasNext()) {
import com.sunmi.scan.Config;
import com.sunmi.scan.Image;
import com.sunmi.scan.ImageScanner;
import com.sunmi.scan.Symbol;
import com.sunmi.scan.SymbolSet;
/* Create decoded images. Width and height are the width and height of the
camera’s preview resolution. Generally, the higher the resolution is, the clearer the
image is but the lower the decoding speed is. A resolution no bigger than 1280*720 is
recommended, like 640*480, 800*480, 1280*720. You can get the resolution
supported by the current device by getSupportedPreviewSizes. The default format of
the preview image is YCbCr_420_SP, and the parameter “Y800” means to take the
“Y” component in YUV.
*/
4. Decode images. If you use an Android camera, you can directly call the preview
data to decode, by PreviewCallback.onPreviewFrame(byte[] data, Camera camera).
source.setData(data); // Fill the raw data of the camera as the image data.
If the images are of other formats, such as photos from your gallery, the format needs
to be converted to BMP file format; If they are color images, they also need to be in
grayscale, for currently the decoding library can only handle images in grayscale (i.e.
the brightness value of each pixel point ranges from 0 to 255).
if(result >0){
}
Additional Guidance
1. Types of code currently supported by SUNMI’s scanning SDK include:
2. Remember to update the two files libsunmiscan.so and sunmiscan.jar when you
update the decoding library.
3. Although the latest decoding library provides 64-bit version (under the arm64-v8a
folder), devices on 64-bit platforms are also compatible with 32-bit ones (under the
armeabi-v7a folder). You can choose the platform type in build.grande.
externalNativeBuild {
cmake {