ZXing Fragment Library


Source link: https://github.com/mitoyarzun/zxingfragmentlib

ZXing Fragment Library

This library allows you to embed a Barcode scanner as a Fragment.

Most of the code was taken from the official ZXing repository, this is basically a re-implementation of CaptureActivity.java.

This was also inspired by another similar library, barcodefragmentlib.

WARNING

I'm currently updating this library, I've updated the original ZXing sources to the latest version and there might be some incompatibilities with older versions of Android.

Please browse the before-rebuild branch to get the previous version.

There are some bugs that prevent the scanning in portrait mode (especially with 1D codes, QR and others should be ok).

I've tested the code and it's working (at least) in Android 2.1 (Eclair), 2.3 (Gingerbread) and 4.4 (KitKat). If yours doesn't work, please create an issue.

Goals

Here are the basic guidelines for this project. As always, suggestions are appreciated :)

  • Provide a simple library to scan codes using ZXing's core library.
  • Be compatible with Android 2.1 and up.
  • Work out of the box (or almost).
  • Facilitate customization and/or configuration.

Usage

  1. Add the library as a module dependency to your app.
  2. Add the ZXing core library (the jar is included in libs/zxing-core-2.3.jar)
  3. Add the following permissions to your AndroidManifest.xml
 <uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />
  1. Extend the BarCodeScannerFragment class and add a callback somewhere:

    this.setmCallBack(new BarCodeScannerFragment.IResultCallback() {
    
      @Override
      public void result(Result lastResult) {
    
    Log.v("zxingfragmentlib", lastResult.toString());
    
      
    }
     
    }
    );
    
  2. Enjoy!

A sample activity is included, look at SampleActivity.java, SampleFragment.java and sample_activity.xml to get an idea.

Contributing

Any code improvements and bug reports are appreciated, just submit a pull request or open an issue.

TODO

  • Remove unused XMLs
  • Remove PreferencesActivity
  • Add front-camera selector
  • Test in more devices

Author

Jaime Oyarzun [email protected]

The original ZXing project is at https://github.com/zxing/zxing

Resources

As the official Android Gradle plugin cannot resolve the native dependencies, the .so files would not be copied to the sub-directory of jniLibs. This plugin is aim to solve this problem, in addition to provide file rename and abi filtering utility functions.

A gradle plugin to calculate Android-friendly version names and codes from git tags. If you are tired of manually updating your Android build files for each release, or generating builds that you can't trace back to code, then this plugin is for you!

A set of Gradle plugins to build and use Xtext languages and the Xtend programming language.

A Gradle plugin for building Java and Android-based ROS2 projects.

This gradle plugin is designed for allowing Android dependencies using git. This allows you to use any Android library from a git repo based on commit or branch.

ShapeShifter provides a polygon shaped ImageView.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes