Closed HectorFGarcia closed 8 years ago
You're right, the parameter should be true
in that case.
Does the "Barcode Scanner" application from the play store work on that device?
I'll try the app, but now I was checking the examples and "ContinuousCaptureActivity" example works.
Could be because I'm using the CompoundBarcodeView inside a Fragment instead an Activity? I don't know what I'm missing if examples works and my code don't but in other devices it does.
My code is really simple:
barcodeScannerView = (CompoundBarcodeView) v.findViewById(R.id.barcode_scanner);
barcodeScannerView.decodeContinuous(new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
// ...
}
@Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
// ...
}
});
....
scan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (barcodeScannerView.getVisibility() == View.GONE) {
barcodeScannerView.resume();
barcodeScannerView.setVisibility(View.VISIBLE);
} else {
barcodeScannerView.setVisibility(View.GONE);
barcodeScannerView.pause();
}
//scanner.scan();
}
});
....
@Override
public void onResume() {
super.onResume();
if (barcodeScannerView.getVisibility() == View.VISIBLE)
barcodeScannerView.resume();
}
....
<com.journeyapps.barcodescanner.CompoundBarcodeView
android:id="@+id/barcode_scanner"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="70dp"
android:visibility="gone"
app:zxing_scanner_layout="@layout/custom_barcode_scanner"/>
Not sure if it has an effect here, but some devices don't like it if the preview is not visible. You can try calling resume()
only after the setVisibility()
call. Alternatively, you can try creating a new component and add/remove it dynamically instead of doing the show/hide.
I removed all the views stuff and still nothing. I just use this:
barcodeScannerView = (CompoundBarcodeView) v.findViewById(R.id.barcode_scanner);
barcodeScannerView.decodeContinuous(new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
// ...
}
@Override
public void possibleResultPoints(List<ResultPoint> resultPoints) {
// ...
}
});
barcodeScannerView.resume();
And the same XML without the visibility.
Same exception :(
Update: If I reboot the device, then the scanner works until I finish the app. At the second start, the exception is back again. In the example, scanner works all the time, so WTF.
FINALLY!
It was all because a library wich somehow interferes with the camera. That lib is only loaded in this device, so that explains why the other devices works fine and why example works too while the app doesn't. I don't know how that library interferes the camera, apparently it's not related to it.
Sorry about wasting your time, at least I found a little bug in the process.
Great library, by the way, I tested a lot of them and this one is awesome.
Hi, how the problem is solved? @HectorFGarcia @rkistner
I'm not using the camera at all. only the lib is using it but has the same exception. @HectorFGarcia @rkistner so what was the solution?
I tried this lib on four devices (4.1.2, 4.2.2, 6.0.1, 4.0.1). It works fine on three of them, but the last one (4.0.1) is getting this exception.
I was tracking down where the problem start and it comes from here:
That "message.obj" is null so "size" is null too. Also, before the this exception, I'm getting this warning in logcat:
And it comes from here:
That line provokes this exception:
So I don't know why this happens. I'm using barcodeScannerView.decodeContinuous(..) inside a Fragment, by the way. And as I said befote, It works fine in all devices excepts one.
P.S. While I was looking into the code, I saw this too:
Shouldn't be "setDesiredParameters(true);" in the second case?