Home

Awesome

ZXScanLib for Android v2

Project merged and moved !

IMPORTANT INFORMATION - this project is now merged with another one, called CAMView: https://github.com/LivotovLabs/CamView

All future development of this scanner library will happen inside the CAMView repository. Please post your issues and download sources, new snapshots and releases from there: https://github.com/LivotovLabs/CamView

We believe both ZXScanLib and CAMView have a lot of common (moreover, ZXScanLib depends on CAMView), so having it as a single solid project will boost productivity, add more transparency and reduce number of bugs.

All previous ZXScanLib releases will remain in the maven repo forever, so no current production apps should be affected.

Old Project Informatin (deprecated)

Screenshot

Usage

Simply include ScannerView in your layout XML.

<eu.livotov.zxscan.ScannerView
    android:id="@+id/scanner"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Add scanned code event receiver.

ScannerView scanner = (ScannerView) findViewById(R.id.scanner);
scanner.setScannerViewEventListener(new ScannerView.ScannerViewEventListener()
{
            public boolean onCodeScanned(final String data)
            {
                scanner.stopScanner();
                Toast.makeText(this, "Data scanned: " + data, Toast.LENGTH_SHORT).show();
                return true;
            }
});

Start scanner when you need it.

scanner.startScanner();

That't it ! Alternatively you may operate with the ScannerFragment instead. The only difference is that ScannerFragment starts and stops scanner automatically when fragment is resumed/paused.

See also the simple demo application that is included.

Known Issues

Getting It

ZXScanLib is available from maven repository:

Available versions:

Please note that versions 0.9.x and 1.x are from previous generation of this library - they are completely different in api and obsolete.

Gradle:


repositories {
    ...
    maven { url 'http://maven.livotovlabs.pro/content/groups/public' }
    ...
}

compile ('eu.livotov.labs:zxscanlib:2.0.1@aar') {transitive=true}

Note, that ZXScanLib depends internally on CAMView project, so transitive=true statement is required in order to compile.

Tweaking The Scanner

All configuration is made on ScannerView instance. If you're operating with ScannerFragment, you can get ScannerView instance by calling getScanner() method.

If you want complete scanner layout rework, extend ScannerView and override the getScannerLayoutResource() method in order to specify your own layout:

public class MyScannerView extends ScannerView
{
    @Override
    protected int getScannerLayoutResource()
    {
        return R.layout.my_customized_scanner_layout;
    }
}

Note, that your layout MUST contain at least the CAMView object definition with the special ID zxscanlib_camera :

<eu.livotov.labs.android.camview.CAMView
            android:id="@id/zxscanlib_camera"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

Contributing

We're always happy for external help and any contributions !

Credits

Thanks ZXing (https://github.com/zxing/zxing) for the core decoding engine that is used as default processor to decode captured bitmaps !

License

Copyright 2014 Livotov Labs Ltd.

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.