Coder Social home page Coder Social logo

rocketeer007 / qrscanner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codenameone/qrscanner

0.0 0.0 0.0 28.11 MB

CN1Lib for using ZBar scanning in Android apps.

License: MIT License

Shell 1.20% JavaScript 0.24% C++ 59.50% Objective-C 20.86% Java 15.26% C# 0.29% CSS 0.08% HTML 2.57%

qrscanner's Introduction

QRScanner

CN1Lib for using ZBar scanning in Android apps.

The built in Codename One implementation of CodeScanner works well on iOS but has some issues on Android.
This module works around those issues by embedding ZBar into the Android build.

This removes the reliance on an external scanning app to be installed and seems to scan faster.

It does add several megabytes to the final .apk file size.

How to use

Installation

Maven Projects

Add the following dependency to your project's common/pom.xml file:

<dependency>
    <groupId>com.codenameone</groupId>
    <artifactId>qrscanner-lib</artifactId>
    <version>2.0.2</version>
    <type>pom</type>
</dependency>

If you want to hack on the sources, and use a modified version, you can just clone this repository and run mvn install to install it into your local Maven repository.

Ant Projects

Use Codename One Preferences to install the QRScanner library.

or

Build this project from source, then find the .cn1lib file in the common/target directory, and copy it to the "libs" directory of your Codename One application project, and select "Refresh Libs".

Example Code

Basically use QRScanner instead of CodeScanner.

QRScanner.scanQRCode(new ScanResult() {
    public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
        Dialog.show("Completed", contents, "OK", null);
    }
    public void scanCanceled() {
        Dialog.show("Cancelled", "Scan Cancelled", "OK", null);
    }
    public void scanError(int errorCode, String message) {
        Dialog.show("Error", message, "OK", null);
    }
});

Converting an existing app

It should pretty much be a drop in replacement for CodeScanner. If you need to detect if code scanning is supported on the current platform then you need to keep the original check do not change this line to QRScanner:

if (CodeScanner.getInstance() != null) {
    QRScanner.scanQRCode(myScanResult);
} else {
    Dialog.show("Not Supported","QR Code Scanning is not available on this device","OK",null);
}

Configuring Types to Scan For

By default, the scanner will look for bar codes of type EAN13 in barcode scanning mode, and QR_CODE in QR code scanning mode.
If you want to detect ALL supported code types, you can call the following before making the call to scan the code:

Display.getInstance().setProperty("scanAllCodeTypes", "true");

Building from Source

  1. Clone this repository
  2. Set JAVA_HOME to a JDK 1.8 or JDK 11 installation
  3. mvn install

qrscanner's People

Contributors

shannah avatar dignz avatar nickm-littlemonkey avatar nickofthesouth avatar shai-almog avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.