The Google code scanner API provides a complete solution for scanning codes without requiring your app to request camera permission.

Overview

Android Google Code Scanner

The Google code scanner API provides a complete solution for scanning codes without requiring your app to request camera permission, while preserving user privacy. This is accomplished by delegating the task of scanning the code to Google Play services and returning only the scan results to your app. All image processing occurs on the device and Google doesn't store the results or image data.

Android Language Badge

Android-Google Code Scanner - Example

Kindly use the following links to use this library:

In your top-level settings.gradle file, include Google's Maven repository and Maven central repository in under the dependencyResolutionManagement block:

dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
  }
}

Add the Google Play services dependency for the play-services-code-scanner SDK to your module's Gradle build file, which is commonly app/build.gradle:

dependencies {
  implementation 'com.google.android.gms:play-services-code-scanner:16.0.0-beta1'
}

You can configure your app to have Google Play services automatically download the scanner module to the device while your app is installed from the Play Store. If you skip this step, Google Play services will download the scanner module the first time it is used, if it has not already been installed for another use case.

<application ...>
  ...
  <meta-data
      android:name="com.google.mlkit.vision.DEPENDENCIES"
      android:value="barcode_ui"/>
  ...
</application>

How to use

(Optional) Configure the code scanner

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. For example, to detect only Aztec code and QR codes, build a GmsBarcodeScannerOptions object as in the following example:

//**** kotlin ****
val options = GmsBarcodeScannerOptions.Builder()
                .setBarcodeFormats(
                    Barcode.FORMAT_QR_CODE,
                    Barcode.FORMAT_AZTEC
                )
                .build()
//**** java ****
GmsBarcodeScannerOptions options = new GmsBarcodeScannerOptions.Builder()
    .setBarcodeFormats(
        Barcode.FORMAT_QR_CODE,
        Barcode.FORMAT_AZTEC)
    .build();

Get an instance of GmsBarcodeScanner

//**** kotlin ****
val scanner = GmsBarcodeScanning.getClient(this)
// Or with a configured options
// val scanner = GmsBarcodeScanning.getClient(this, options)
//**** java ****
GmsBarcodeScanner scanner = GmsBarcodeScanning.getClient(this);
// Or with a configured options
// GmsBarcodeScanner scanner = GmsBarcodeScanning.getClient(context, options);

Request a code scanning by calling startScan()

//**** kotlin ****
scanner.startScan()
    .addOnSuccessListener { barcode ->
        // Task completed successfully
    }
    .addOnFailureListener { e ->
        // Task failed with an exception
    }
//**** java ****
scanner
    .startScan()
    .addOnSuccessListener(
        barcode -> {
          // Task completed successfully
        })
    .addOnFailureListener(
        e -> {
          // Task failed with an exception
        });

Handle the resulting Barcode

//**** kotlin ****
val rawValue: String? = barcode.rawValue
//**** java ****
String rawValue = barcode.getRawValue();
Watch the code here (MainActivity.java) and ref Google code scanner (Beta)
Any Queries? or Feedback, please let me know by opening a new issue!

Contact

Prabhakar Thota

If you appreciate my work, consider buying me a cup of β˜• to keep me recharged 🀘 by PayPal

License

Copyright 2022 MyInnos

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...

A minimal WHIP implementation for the Raspberry Pi. It sends Mic and Camera to a WHIP endpoint

whipi A minimal WHIP implementation for the Raspberry Pi. It sends Camera Mic to a WHIP endpoint. Requires a Raspberry Pi with a PiCam and Java 11. It

Oct 27, 2022

A virtual camera based on Xposed

A virtual camera based on Xposed

Dec 31, 2022

Allows changing of hurt animation modifier, changing how much the user's camera moves after the player being hurt.

Hurt Animation Modifier Allows changing of hurt animation modifier, changing how much the user's camera moves after the player being hurt. Credit to W

May 17, 2022

WebRTC for React-Native. Allows camera to zoom on the fly while streaming and change max bitrate.

WebRTC for React-Native. Allows camera to zoom on the fly while streaming and change max bitrate.

rn-webrtc This repo is forked from react-native-webrtc. A WebRTC module for React Native. Support iOS / macOS / Android. Support Video / Audio / Data

Aug 7, 2022

A simple app to use Xposed without root, unlock the bootloader or modify system image, etc.

A simple app to use Xposed without root, unlock the bootloader or modify system image, etc.

δΈ­ζ–‡ζ–‡ζ‘£ Introduction VirtualXposed is a simple App based on VirtualApp and epic that allows you to use an Xposed Module without needing to root, unlock t

Jan 8, 2023

InstaKill is a shitty addon for the Meteor Client created without knowledge of the code

InstaKill About InstaKill is a shitty addon for the Meteor Client created without knowledge of the code. The only thing this addon adds is InstaKill e

Jun 15, 2022

A complete and performing library to highlight text snippets (EditText, SpannableString and TextView) using Spannable with Regular Expressions (Regex) for Android.

A complete and performing library to highlight text snippets (EditText, SpannableString and TextView) using Spannable with Regular Expressions (Regex) for Android.

Highlight A complete and performing library to highlight text snippets (EditText/Editable and TextView) using Spannable with Regular Expressions (Rege

Dec 22, 2022

In this course, we will learn how to build a complete full-stack web application using Spring boot as backend and React (React Hooks) as frontend

In this course, we will learn how to build a complete full-stack web application using Spring boot as backend and React (React Hooks) as frontend. We will use MySQL database to store and retrieve the data.

Dec 22, 2022

A near-real-time Mesh Join Algorithm Implementation provided with a Complete Data warehouse for METRO

A near-real-time Mesh Join Algorithm Implementation provided with a Complete Data warehouse for METRO

Mesh Join Algorithm and Data Warehouse A complete Mesh-Join Algorithm Implementation as provided in the paper R-MESHJOIN . This is demonstrated by the

Aug 11, 2022
Owner
Prabhakar Thota
Mobile Engineer, UI/UX. I believe in the quote, "Creativity is thinking up new things. Innovation is doing new things." Happy Coding :)
Prabhakar Thota
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

Tencent 16.6k Dec 30, 2022
corrects your sitting posture and provides feedback in real time in conjunction with the app. A sensor of 31 cells detects your posture to get better life-wellness

Notichair μ‹€μ‹œκ°„ μžμ„ΈλΆ„μ„ 및 ꡐ정 μŠ€λ§ˆνŠΈμ²΄μ–΄ ?? 상λͺ…λŒ€ν•™κ΅ PRIME κ²½μ§„λŒ€νšŒ μˆ˜μƒ ?? μš”κ΅¬μ‚¬ν•­ 31-cell sensor (mdxs-16-5610) λͺ©μ°¨ 1. μ†Œκ°œ ν”„λ‘œμ νŠΈ λ‚΄μš© μ†Œκ°œ 2. 개발 ν™˜κ²½ 사전 μ„€μ • 및 ν™˜κ²½ ꡬ좕 3. κΈ°λŠ₯ Sensors Ap

Minuk_LEE 3 Jan 15, 2022
With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any other file server

React Native In-App update With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any o

Nepein Andrey 7 Dec 21, 2022
A desktop app to generate QR codes.

qrcode-generator A desktop GUI app to generate QR codes. Currently a fun project and a work-in-progress. GitHub URL: https://github.com/abhinavgunwant

Abhinav Gunwant 2 Aug 2, 2022
Google App Engine Standard Environment Source Code for Java 8 and Java11

Google App Engine Standard Environment Source Code for Java 8 and Java11. This is a repository that contains the Java Source Code for Google App Engin

Google Cloud Platform 167 Jan 2, 2023
Ti.googlepay - Add Google Pay to your app

Google Pay Add Google Pay to your app: Events available success canceled error Methods setupPaymentGateway: name, apiKey createPaymentRequest: environ

Michael Gangolf 4 Nov 7, 2022
An app that mixes emojis using Google Emoji Kitchen API.

EmojiMixer An app that mixes emojis using Google Emoji Kitchen API mainly inspired from emojimix. The project is just broken since I'm not active anym

Ilyasse 15 Aug 24, 2022
Aye - an open source tool for scanning images on Kubernetes cluster

Aye is an open source tool for scanning images on Kubernetes cluster. It uses Anchore CLI behind the scenes to get information about all images that are currently on the cluster. It also provides Prometheus metrics for each image, so teams are aware of different levels of vulnerabilities found inside them.

null 4 Sep 4, 2022
Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

Spring Cloud Alibaba A project maintained by Alibaba. See the δΈ­ζ–‡ζ–‡ζ‘£ for Chinese readme. Spring Cloud Alibaba provides a one-stop solution for distribut

Alibaba 24.4k Jan 1, 2023
Dual Camera, IMU, and GPS data recorder for Android

Visual-Inertial Recorder (VIRec) Record camera frames at ~30fps from one or two camera sensors, Inertial Measurement Unit (IMU) measurements at ~100Hz

AUT 3D Vision 17 Oct 24, 2022