eason1196 / hms-scan-demo

Sample code for demonstrating Huawei HMS ScanKit capabilities. It illustrates how to help developers quickly build code scanning capabilities.

Home Page:https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/scan-introduction-4?ha_source=hms1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HMS Core Scan Kit Sample Code (Android)

English | 中文

Contents

Introduction

The sample code shows how to quickly build barcode scanning functions into an app using the capabilities in HMS Core Scan Kit.

You can use HMS Toolkit to quickly run the sample code. HMS Toolkit supports one-stop kit integration, and provides functions such as free app debugging on remote real devices. To learn more about HMS Toolkit, please refer to the HMS Toolkit documentation.

Preparations

  1. Create an app and configure its information in AppGallery Connect. For details, please refer to Configuring App Information in AppGallery Connect.

  2. Add the AppGallery Connect configuration file of your app.

  3. Configure the Maven repository address for the HMS Core SDK.

Environment Requirements

Android Studio 3.0 or later and JDK 1.8.211 or later A device that runs EMUI 3.0 or later and is compatible with HMS Core (APK) 4.0.0.200 or later

Sample Code

The demo shows the following modes for barcode scanning in different scenarios:

  1. Default View

In this mode, your app will call activities provided by this kit and obtain the scanning result through an asynchronous callback API. Users will be able to scan barcodes directly with the camera or from local images imported to the app.

Find the sample code for this mode in example/scankitdemo/MainActivity.java.

  1. Customized View

In this mode, your app will create a RemoteView object and obtain the scanning result through an asynchronous callback API. Users will be able to scan barcodes directly with the camera or from local images imported to the app.

Find the sample code for this mode in example/scankitdemo/DefinedActivity.java.

  1. Bitmap

In this mode, your app will implement bitmap-based barcode scanning and obtain the scanning result through related APIs. Your app will be able to obtain bitmaps by starting the camera or importing local images, and decode the bitmaps by calling decodeWithBitmap.

Find the sample code for this mode in example/scankitdemo/CommonActivity.java and example/scankitdemo/CommonHandler.java.

  1. MultiProcessor

When working together with ML Kit, Scan Kit provides the capability of detecting both barcodes and human faces. Frame data is transmitted and decoded through MultiProcessor APIs.

Find the sample code for this mode in example/scankitdemo/CommonActivity.java and example/scankitdemo/CommonHandler.java.

  1. Generating barcodes

Call the buildBitmap API to generate barcodes.

Find the sample code for barcode generation in example/scankitdemo/GenerateCodeActivity.java.

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.

About

Sample code for demonstrating Huawei HMS ScanKit capabilities. It illustrates how to help developers quickly build code scanning capabilities.

https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/scan-introduction-4?ha_source=hms1

License:Apache License 2.0


Languages

Language:Java 61.6%Language:Kotlin 38.4%