English | 中文
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:
Android Studio 3.0 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.200 or a generic device running Android 4.4 or later.
Barcode scanning 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
.
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:
huawei-mobile-services
. Huawei experts will answer your questions.If you encounter any issues when using the sample code, submit your issues or submit a pull request.
The sample code is licensed under Apache License 2.0.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
Activity
Community
Health
Trend
Influence
:Code submit frequency
:React/respond to issue & PR etc.
:Well-balanced team members and collaboration
:Recent popularity of project
:Star counts, download counts etc.