Play Store 512

Cordova Google code scanner plugin demo

Demo app for testing the cordova-plugin-google-code-scanner, which allows scanning of codes without requesting camera permissions using the new Google Play Services barcode API. Source code available in GitHub.

Apache Cordova logo phonegap

Introduction

The Google code scanner allows scanning of codes with the new play-services-code-scanner library. This API is based on the ML Kit for Android, but with a drastically smaller footprint, there’s no need to bundle the complete ML Kit with your app. Instead, the code scanner only requires a small UI module downloaded on-demand by Google Play Services on first use.

This API is offered in beta, which means it might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.

Prerequisites

  • Android 5+
  • Google Play Services updated

Android screenshots

Methods

This is a summary of the demo app’s methods. Refer to plugin’s README for details

startScan

Opens the code scanner view to scan barcode with the selected format. If you know which barcode formats you expect to read, you can improve the speed of the barcode detector by configuring it to only detect those formats.

To detect multiple formats, type the sum of the Barcode constants to the provided text area.

getBarcodeConstant

Retrieve the Barcode format constant value by its String name. Useful to scan new barcode formats added in the future.

Predefined barcode formats

The following barcode constants are pre-defined by the plugin for your convenience:

  • FORMAT_ALL_FORMATS
  • FORMAT_CODE_128
  • FORMAT_CODE_39
  • FORMAT_CODE_93
  • FORMAT_CODABAR
  • FORMAT_DATA_MATRIX
  • FORMAT_EAN_13
  • FORMAT_EAN_8
  • FORMAT_ITF
  • FORMAT_QR_CODE
  • FORMAT_UPC_A
  • FORMAT_UPC_E
  • FORMAT_PDF417
  • FORMAT_AZTEC

Remarks

  • Camera usage permission not required.
  • Whenever the Google Play Store app is disabled, the UI module won’t be downloaded.

Download demo app

Feedback

Use the comments section here for demo app-related issues, and the GitHub issues tracker for plugin-related ones.

More plugin demo apps

Check out the following Cordova plugin demo apps ready for download on your device. The source code is included for compiling to any platform.

Disclaimer

The content in this post is for general information purposes only. The information is provided by the author and/or external sources and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the post for any purpose. Some of the content and images used in this post may be copyrighted by their respective owners. The use of such materials is intended to be for educational and informational purposes only, and is not intended to infringe on the copyrights of any individuals or entities. If you believe that any content or images used here violate your copyright, please contact us and we will take appropriate measures to remove or attribute the material in question.