QRCodeReaderView icon indicating copy to clipboard operation
QRCodeReaderView copied to clipboard

Flashlight is not detected or there is no option to change front camera or back

Open Tufan21 opened this issue 9 years ago • 2 comments

hii sir i am using these in fragment ..already enabled these feature but it is not working

i am using these version compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.1'

    mydecoderview = (QRCodeReaderView)rootView. findViewById(R.id.qrdecoderview);
    mydecoderview.setOnQRCodeReadListener(this);
   
 // Use this function to enable/disable decoding
    mydecoderview.setQRDecodingEnabled(true);

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

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

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

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

Tufan21 avatar Dec 09 '16 13:12 Tufan21

Sorry, I don't catch your question, can you explain me again what's happening/not working?

dlazaro66 avatar Jan 28 '17 14:01 dlazaro66

Hi, I cannot enabled torch. My code simple:

MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.dlazaro66.qrcodereaderview.QRCodeReaderView;

public class MainActivity extends AppCompatActivity implements QRCodeReaderView.OnQRCodeReadListener {

    private QRCodeReaderView qrCodeReaderView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        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();
    }

    @Override
    public void onQRCodeRead(String text, PointF[] points) {
        Log.e("kanan", text);
    }

    @Override
    protected void onResume() {
        super.onResume();
        qrCodeReaderView.startCamera();
    }

    @Override
    protected void onPause() {
        super.onPause();
        qrCodeReaderView.stopCamera();
    }

}

And activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.dlazaro66.qrcodereaderview.QRCodeReaderView
        android:id="@+id/qrdecoderview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

And when I use debug CameraManager in package com.google.zxing.client.android.camera; call this function and debug result is theCamera: null, enabled: true:

public synchronized void setTorchEnabled(boolean enabled) {
    OpenCamera theCamera = openCamera;
    if (theCamera != null && enabled != configManager.getTorchState(theCamera.getCamera())) { 
      boolean wasAutoFocusManager = autoFocusManager != null;
      if (wasAutoFocusManager) {
        autoFocusManager.stop();
        autoFocusManager = null;
      }
      configManager.setTorchEnabled(theCamera.getCamera(), enabled);
      if (wasAutoFocusManager) {
        autoFocusManager = new AutoFocusManager(theCamera.getCamera());
        autoFocusManager.start();
      }
    }
  }

seyidkanan avatar Aug 04 '18 09:08 seyidkanan