I've been trying to solve the problem for 3 days, but I still have not found the answer. I want to add a ZOOM to the camera while scanning the qrcode through the Zxing scanner.
build.gradle:
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
Xml:
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
ScannerFragment:
@Override
public void onResume() {
super.onResume();
activateScanner();
}
private ViewGroup contentFrame;
private ZXingScannerView zXingScannerView;
private void activateScanner() {
if(zXingScannerView != null) {
if(zXingScannerView.getParent()!=null) {
((ViewGroup)
zXingScannerView.getParent()).removeView(zXingScannerView); // to
prevent crush on re adding view
}
contentFrame.addView(zXingScannerView);
if(zXingScannerView.isActivated()) {
zXingScannerView.stopCamera();
}
zXingScannerView.startCamera(camId);
zXingScannerView.setFlash(isFlash);
//zXingScannerView.setAutoFocus(isAutoFocus);
}
}
I added SeekBar And with it I want to control the zoom of the camera.
private Camera cameraZoom;
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
try {
Camera.Parameters parameters = cameraZoom.getParameters();
}
catch (NullPointerException e) {
Log.d("NullP",e.getMessage());
}
}
LOG:
D/NullP: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference
I tried to do this using the code above, but there were only errors
Please tell me how to do this.
This line is missing in your code.