Giter Club home page Giter Club logo

qrcodereaderview's Introduction

QRCodeReaderView Download Android Arsenal Build Status

Disclaimer: This project is no longer actively maintained

Modification of ZXING Barcode Scanner project for easy Android QR-Code detection and AR purposes.

This project implements an Android view which show camera and notify when there's a QR code inside the preview.

Some Classes of camera controls and autofocus are taken and slightly modified from Barcode Scanner Android App.

You can also use this for Augmented Reality purposes, as you get QR control points coordinates when decoding.

Usage

  • Add a "QRCodeReaderView" in the layout editor like you actually do with a button for example.
  • In your onCreate method, you can find the view as usual, using findViewById() function.
  • Create an Activity which implements onQRCodeReadListener, and let implements required methods or set a onQRCodeReadListener to the QRCodeReaderView object
  • Make sure you have camera permissions in order to use the library. (https://developer.android.com/training/permissions/requesting.html)
 <com.dlazaro66.qrcodereaderview.QRCodeReaderView
        android:id="@+id/qrdecoderview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
  • Start & Stop camera preview in onPause() and onResume() overriden methods.
  • You can place widgets or views over QRDecoderView.
public class DecoderActivity extends Activity implements OnQRCodeReadListener {

    private TextView resultTextView;
	private QRCodeReaderView qrCodeReaderView;

	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_decoder);
        
        qrCodeReaderView = (QRCodeReaderView) findViewById(R.id.qrdecoderview);
        qrCodeReaderView.setOnQRCodeReadListener(this);

    	  // Use this function to enable/disable decoding
        qrCodeReaderView.setQRDecodingEnabled(true);

        // Use this function to change the autofocus interval (default is 5 secs)
        qrCodeReaderView.setAutofocusInterval(2000L);

        // Use this function to enable/disable Torch
        qrCodeReaderView.setTorchEnabled(true);

        // Use this function to set front camera preview
        qrCodeReaderView.setFrontCamera();

        // Use this function to set back camera preview
        qrCodeReaderView.setBackCamera();
    }

    // Called when a QR is decoded
    // "text" : the text encoded in QR
    // "points" : points where QR control points are placed in View
	@Override
	public void onQRCodeRead(String text, PointF[] points) {
		resultTextView.setText(text);
	}
    
	@Override
	protected void onResume() {
		super.onResume();
		qrCodeReaderView.startCamera();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		qrCodeReaderView.stopCamera();
	}
}

Add it to your project

Add QRCodeReaderView dependency to your build.gradle

dependencies{
      compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
}

Note: There is an issue with gradle 2.10, if you declare your dependency and it can't be found in jCenter repository (could not find qrcodereaderview.jar Searched in the following locations: or similar), try to declare the library dependency like this:

dependencies{
      compile ('com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3@aar'){
        transitive = true
      }
}

And in some cases, you need to clean your Gradle cache ./gradlew build --refresh-dependencies

Do you want to contribute?

Please send a PR or open an issue with your comments. See CONTRIBUTING file for further information

Libraries used in this project

Screenshots

Image

Developed By

  • David Lázaro Esparcia
Follow me on Twitter Add me to Linkedin

Who's using it

Does your app use QRCodeReaderView? If you want to be featured on this list drop me a line.

License

Copyright 2017 David Lázaro

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.

qrcodereaderview's People

Contributors

ahmednasir91 avatar anrimian avatar danicomas avatar dlazaro66 avatar eduardocalazansjr avatar kocyigityunus avatar rolf-smit avatar rzetzsche avatar saguinav avatar shem8 avatar stephenvinouze avatar zodani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qrcodereaderview's Issues

How to scan code only once?

This isn't an issue it's more of a question about usage. How do I ensure that the code is scanned only once ?

no class found exception

I have use your library in my project.i have run this project with lolipop version.I used ADT 22.0 version.I have found below error:

04-08 10:30:15.540: E/AndroidRuntime(27571): FATAL EXCEPTION: main
04-08 10:30:15.540: E/AndroidRuntime(27571): Process: com.example.newqrcodereader, PID: 27571
04-08 10:30:15.540: E/AndroidRuntime(27571): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/zxing/qrcode/QRCodeReader;
04-08 10:30:15.540: E/AndroidRuntime(27571): at com.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceCreated(QRCodeReaderView.java:125)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.SurfaceView.updateWindow(SurfaceView.java:579)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:176)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1986)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1077)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5884)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.Choreographer.doCallbacks(Choreographer.java:580)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.Choreographer.doFrame(Choreographer.java:550)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.os.Handler.handleCallback(Handler.java:739)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.os.Handler.dispatchMessage(Handler.java:95)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.os.Looper.loop(Looper.java:135)
04-08 10:30:15.540: E/AndroidRuntime(27571): at android.app.ActivityThread.main(ActivityThread.java:5312)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.reflect.Method.invoke(Native Method)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.reflect.Method.invoke(Method.java:372)
04-08 10:30:15.540: E/AndroidRuntime(27571): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
04-08 10:30:15.540: E/AndroidRuntime(27571): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
04-08 10:30:15.540: E/AndroidRuntime(27571): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.zxing.qrcode.QRCodeReader" on path: DexPathList[[zip file "/data/app/com.example.newqrcodereader-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
04-08 10:30:15.540: E/AndroidRuntime(27571): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
04-08 10:30:15.540: E/AndroidRuntime(27571): ... 19 more
04-08 10:30:15.540: E/AndroidRuntime(27571): Suppressed: java.lang.ClassNotFoundException: com.google.zxing.qrcode.QRCodeReader
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.Class.classForName(Native Method)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
04-08 10:30:15.540: E/AndroidRuntime(27571): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
04-08 10:30:15.540: E/AndroidRuntime(27571): ... 20 more
04-08 10:30:15.540: E/AndroidRuntime(27571): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

continuously scanning

toast shows multiple times once camera reads qr code..i want only single result..how can i fix this issue

java.lang.RuntimeException: Fail to connect to camera

A great work here in this library.
But when i tried to scan BarCode Not QRCode the camera did not open.
You can check these
java.lang.RuntimeException: Fail to connect to camera servicecom.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceCreated(QRCodeReaderView.java:110)

Image Animation is not working on QRCodeReaderView

First I appreciate your work and I like it because from last 10 days I was searching the project to scan qrcode in portrait mode and this is the one which help me alot. The issue that I'm facing is my line image is not moving up and down on the screen. If I invisible the QRCodeReaderView then my animation works perfectly. So help me to figure out this issue.

java.lang.NullPointerException: Attempt to read from field 'int android.graphics.Point.x' on a null object reference

java.lang.NullPointerException: Attempt to read from field 'int android.graphics.Point.x' on a null object reference
at com.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceChanged(QRCodeReaderView.java:183)
at android.view.SurfaceView.updateWindow(SurfaceView.java:593)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

onQRCodeRead() run twice when scanned a QRcode

@OverRide
public void onQRCodeRead(String text, PointF[] points) {
Log.d("TEST","onQRCodeRead");
}

log shows:
10-15 10:36:10.936 10117-10117/[package] D/TEST: onQRCodeRead
10-15 10:36:11.113 10117-10117/[package] D/TEST: onQRCodeRead

barcode can not recognized?

2-dimensional bar code can be recognized very fast, however, barcode could not be.. is there anything wrong?

Doesn;t work on Android 6

FATAL EXCEPTION: main
                                                                     Process: com.waterworx.android, PID: 5836
                                                                     java.lang.RuntimeException: Fail to connect to camera service
                                                                         at android.hardware.Camera.<init>(Camera.java:495)
                                                                         at android.hardware.Camera.open(Camera.java:341)
                                                                         at com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface.open(GingerbreadOpenCameraInterface.java:57)
                                                                         at com.google.zxing.client.android.camera.open.CameraManager.openDriver(CameraManager.java:77)
                                                                         at com.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceCreated(QRCodeReaderView.java:110)
                                                                         at android.view.SurfaceView.updateWindow(SurfaceView.java:583)
                                                                         at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
                                                                         at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
                                                                         at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
                                                                         at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                                         at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                                                                         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                                         at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                         at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                         at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                         at android.os.Handler.handleCallback(Handler.java:739)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                         at android.os.Looper.loop(Looper.java:148)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

import android.hardware.Camera is Deprecated

Hello, i use this lib in my project and i found that now Camera is deprecated. Could you please update this awesome lib using new Camera Lib ? I really appreaciate if you would do that.

Thank You
sorry english is not my native

Method called after release()

When i call for second time to the activy that implements the QRCodeReaderView, Crash throwing this exception Method called after release().

I solved it adding this lines in QRCodeReaderView -> onSurfaceDestroyed() method:

mCameraManager.getCamera().setPreviewCallback(null);
mCameraManager.getCamera().stopPreview();
mCameraManager.getCamera().release();
mCameraManager.closeDriver();

Maybe some calls are redundant.

Java Source Code Location

Hi, noob question: why the main java code is in a separate project? It seems to compile alright (I don't understand why) but I makes harder to inspect you code. To properly get help from both projects I have to open them in separate windows, which makes things harder. Is there an easier way? Shall I try copying the files to one project?

Thanks

How to increase scanning area size?

Hi! this is great library and i love that

but How to increase scanning area size?

i've searched and found the best solution is like this:
http://stackoverflow.com/questions/20398419/how-to-increase-scanning-area-size-in-zxing

and i noticed you used modify or different version of zxing library.

Any hints to to adjust scanning area size that scale out with this library?

i've tried to set the width "<com.dlazaro66.qrcodereaderview.QRCodeReaderView" on the layout.xml then the camera view not scale out image correctly

Please advise and i appreciate for your help, thanks mate :)

AppCompat

This library is incompatible with the AppCompat theme (and android-support library) because it has a styles.xml which redefines the support library's theme. (Theme.Light and Holo later) You are strongly discouraged to use a styles.xml in a library project because of this.

Using QRCodeReaderView in Fragments

Hi,

I just use this lib on a fragment. it runs like a charm but, once container fragment lost focus, it is imposible to get qrCodeReaderView working again. Dont know why stops reading.

Please, help!.

best regards!

How to Run this program and what should i need to run this program..

This is my first post.... im a newbie here
Could anybody please tell me what should i do to run this program...
what should i need to run this program... should i need some applications to make it run?
if yes what is it..?

Thanks in advance Guys....
I would really appreciate your help...
sorry i really dont know what to do but i want to learn...

AUTO_FOCUS_INTERVAL_MS

Hi @dlazaro66

I find Zxing AUTO_FOCUS_INTERVAL_MS is 2000L (2s)

but this project AUTO_FOCUS_INTERVAL_MS setting 5000L (5s).

Can create a function to setting this value?

Thx

Import Project

Please remove *.iml and *.idea from .gitignore and rebuild the project and push so we can import it into android studio directly from git

How to show flash light?

Hello David Lázaro Esparcia,

I am using your library for QR Code scanning functionality. I want flash light functionality too. Please help me how can I do this with your library? Hoping for favorable response.

Thanks .

Constant GC usage, GC_FOR_ALLOC every 100ms

Device: Galaxy S3
Android: 4.4
Lib version: latest


It seems that every 100ms this lib allocates 1876K that Android tries to free. That causes a small FPS drop. Could it be the camera frame (BinaryBitmap and PlanarYUVLuminanceSource)?

Here's my logcat:

04-28 21:40:25.845  13428-13428/com.filip.mojdab D/dalvikvm﹕ GC_FOR_ALLOC freed 1876K, 26% free 19106K/25540K, paused 11ms, total 11ms
04-28 21:40:25.930  13428-13428/com.filip.mojdab D/dalvikvm﹕ GC_FOR_ALLOC freed 1876K, 26% free 19106K/25540K, paused 14ms, total 14ms
04-28 21:40:26.020  13428-13428/com.filip.mojdab D/dalvikvm﹕ GC_FOR_ALLOC freed 1876K, 26% free 19106K/25540K, paused 13ms, total 13ms
04-28 21:40:26.090  13428-13428/com.filip.mojdab D/dalvikvm﹕ GC_FOR_ALLOC freed 1876K, 26% free 19106K/25540K, paused 13ms, total 13ms
04-28 21:40:26.160  13428-13428/com.filip.mojdab D/dalvikvm﹕ GC_FOR_ALLOC freed 1876K, 26% free 19106K/25540K, paused 11ms, total 11ms
04-28 21:40:26.250  13428-13428/com.filip.mojdab D/dalvikvm﹕ GC_FOR_ALLOC freed 1876K, 26% free 19106K/25540K, paused 17ms, total 17ms
..........

How to display a Scanning indicator?

HI all, the library is quite great. But just asking something, is it possible to show a scanning indicator while scanning the QR-code? Like show a ray scan kind of while the camera scans the code.
Is yes, please tell me something about the procedure.
Thanks.

Display blinks the first time

Helo, i used the QRCodeReaderView in a Fragment, and MaterialTabs.
It works, but the display blinks in the first time to create this fragment.

How to stop the reading function at a certain point

When I open the Activity that has the reader view, it reads the code and jumps to onQRCodeRead. How can I stop it from keep reading it? I already used this code but this does not stop the reading only the camera preview:

 public void onQRCodeRead(String s, PointF[] pointFs)
  {
    myTextView.setText("QR code: "+s);
    mydecoderview.getCameraManager().stopPreview();    
  }

Help needed

Hi. thanks for the excellent library.
I need one help.
I need the text value which is being read in the following method in a Activity(CaptureActivity) which is before DecoderActivity.

@OverRide
public void onQRCodeRead(String text, PointF[] points) {
myTextView.setText(text);
}
How can I get this value in CaptureActivity ? Though it might be not specific to this library, but your help would be highly appreciated.

Add AutoFocus

How do I make it auto the camera autofocus on a qrcode ?

com.google.zxing.FormatException and com.google.zxing.ChecksumException

Greetings

Great library is just what I need to give my project extra value, thanks, but Im have this problem.

Im getting this exceptions com.google.zxing.FormatException and com.google.zxing.ChecksumException

First I thought I was doing something wrong, so I try using XZING QrReader and worked instantly, so I create another Qr using an online QR generator, same problem and XZING read it just like before.

Any Idea?

How to import this project in Eclipse

How do I import this project in Eclipse? I know those gradle files show that you should Android Studio, but that program has given me way to many headaches. Could someone make this project into a jar file?

InflateException in sample on Android 2.3

It happens only on Android 2.3. 4+ is fine.
Stacktrace:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.qr_readerexample/com.example.qr_readerexample.DecoderActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.dlazaro66.qrcodereaderview.QRCodeReaderView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.dlazaro66.qrcodereaderview.QRCodeReaderView
            at android.view.LayoutInflater.createView(LayoutInflater.java:518)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
            at android.app.Activity.setContentView(Activity.java:1657)
            at com.example.qr_readerexample.DecoderActivity.onCreate(DecoderActivity.java:25)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
            at android.app.Activity.setContentView(Activity.java:1657)
            at com.example.qr_readerexample.DecoderActivity.onCreate(DecoderActivity.java:25)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.dlazaro66.qrcodereaderview.QRCodeReaderView.init(QRCodeReaderView.java:96)
            at com.dlazaro66.qrcodereaderview.QRCodeReaderView.<init>(QRCodeReaderView.java:75)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
            at android.app.Activity.setContentView(Activity.java:1657)
            at com.example.qr_readerexample.DecoderActivity.onCreate(DecoderActivity.java:25)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)

Camera crashes on some devices: java.lang.RuntimeException: startPreview failed

My app crashes on some devices giving me java.lang.RuntimeException: startPreview failed error
in "Camera Manager" class in line 138 "theCamera.startPreview();"

It works fine on some devices, Samsung S6, HTC One M8 with versions 5.1 and 6,0.

However it crashes on Samsung S3 with version 4.3 along with other devices

Failed to connect to camera service

hi,
i write codes as following,same to your demo

  1. find QRCodeReaderView in xml
  2. add listener
  3. onresume startpreview and onpause stop it

i have two activity,both need to read qrcode,and when i jump first activity to another ,a problem occurs:Failed to connect to camera service.

please help.thanks a lot

Duplicate zip Entry

Whenever added project containg 'QRCoderView', the error occurs

"Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/dlazaro66/qrcodereaderview/QRCodeReaderView$OnQRCodeReadListener.class.".

Please help me to know what is it

java.lang.NullPointerException: Attempt to invoke virtual method

Hey Dlazaro

App crashes when I try to call startPreview() virtual methods on Marshmellow (6.0.1)

Here is the device spec:
Nexus 5
6.0.1
Here is the code that I call getCameraManager

@Override protected void onResume() { super.onResume(); if (mAllPermissionGranted) mQrDecoderView.getCameraManager().startPreview(); }

Here is exception:

Process: com.healthed, PID: 23733 java.lang.RuntimeException: Unable to resume activity {com.healthed/com.healthed.ui.scan.qr.QrScanActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.zxing.client.android.camera.open.CameraManager com.dlazaro66.qrcodereaderview.QRCodeReaderView.getCameraManager()' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.zxing.client.android.camera.open.CameraManager com.dlazaro66.qrcodereaderview.QRCodeReaderView.getCameraManager()' on a null object reference at com.healthed.ui.scan.qr.QrScanActivity.onResume(QrScanActivity.java:87) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258) at android.app.Activity.performResume(Activity.java:6327) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

java.lang.RuntimeException: startPreview failed

java.lang.RuntimeException: startPreview failed
at android.hardware.Camera.startPreview(Native Method)
at com.google.zxing.client.android.camera.open.CameraManager.startPreview(CameraManager.java:138)

Reverse QR Camera

Hello, I have made an application based on your code and the scanner is turned 180 degrees, i tried to change rotation in mCameraManager.getCamera().setDisplayOrientation(90) but doesnt work, throws nullpointerexception in CameraManager.

¿What can i do?

PD: My phone is Nexus 5x

Regards

How to pause scanner

When I point the camera to an qr-code, it read the code continuously without a pause. Is there anyway to pause it without calling stopPreview(), and continue after I handle the result?

Bad auto-focus

I think this project doesn't use the parts of ZXing that do the autofocusing.

It seems to only do it at big intervals, the image is really blurry which means I have to wait 10-15 seconds in order to scan a QR code.

I'm running latest version on Galaxy S3 (Android 4.4) with zxing-core:3.2

How to Read again QR code?

When Activity called first time its create object of QRCodeReaderView and scan QR code at first time but i want to scan again QR code on click of Start/stop button but how ?please tell me.

Thank you

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.