Skip to content

Latest commit

 

History

History
78 lines (37 loc) · 4.89 KB

README.md

File metadata and controls

78 lines (37 loc) · 4.89 KB

HMS Core Scan Kit Sample Code (Android)

English | 中文

Contents

Introduction

This sample code shows how to quickly build barcode scanning functions into your app using the capabilities of the HMS Core Scan Kit. Currently, Scan Kit supports the following barcode formats:

Environment Requirements

Android Studio 3.6.1 or later and JDK 1.8.211 or later.

A Huawei device that runs EMUI 3.0 or later, compatible with HMS Core (APK) 4.0.0 or a generic device running Android 4.4 or later.

Sample Code

Barcode scanning and barcode generating can be achieved in different ways, showcased by the demo.

Default view

The default view mode will start a dedicated Activity provided by Scan Kit that will display a predefined UI, control the camera and pass back the scanning result via the onActivityResult() of the original activity (com.example.scankitdemo.MainActivity in the demo) .

Customized view

In customized view mode, you can define a custom UI, with the help of a com.huawei.hms.hmsscankit.RemoteView, and then obtain the scanning result through an asynchronous callback. As with the default view mode, you do not need to worry about developing the scanning process or controlling the camera. See com.example.scankitdemo.DefinedActivity.

Bitmap

Use this mode when you wish to have full control over the input to the scanning process and the moment when you wish to get the results back. In com.example.scankitdemo.CommonActivity , the demo will pass a Bitmap to com.huawei.hms.hmsscankit.ScanUtil.decodeWithBitmap() (definition).

Multi-processor

Recognize multiple barcodes at the same time. When working together with the HMS ML Kit, Scan Kit can detecting both barcodes and human faces. Frame data is transmitted and decoded through the multi-processor API. See com.example.scankitdemo.CommonActivity and read more about how it works.

Generating barcodes

Generate your own barcodes by calling com.huawei.hms.hmsscankit.ScanUtil.buildBitmap() (definition) in com.example.scankitdemo.GenerateCodeActivity.

Result

Technical Support

You can visit the Reddit community to obtain the latest information about HMS Core and communicate with other developers.

If you have any questions about the sample code, try the following:

  • Visit Stack Overflow, submit your questions, and tag them with huawei-mobile-services. Huawei experts will answer your questions.
  • Visit the HMS Core section in the HUAWEI Developer Forum and communicate with other developers.

If you encounter any issues when using the sample code, submit your issues or submit a pull request.

License

The sample code is licensed under Apache License 2.0.