code-scanner icon indicating copy to clipboard operation
code-scanner copied to clipboard

java.lang.IllegalStateException: Code scanner has already been set

Open babakmhz opened this issue 5 years ago • 1 comments

hello there. that's an issue while starting code scanner on fragment on 'OnCreateView' method.

CodeScannerView scannerView = view.findViewById(R.id.scanner_view); mCodeScanner = new CodeScanner(getActivity(),scannerView); mCodeScanner.setDecodeCallback(new DecodeCallback() { @Override public void onDecoded(@NonNull final Result result) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), result.getText(), Toast.LENGTH_SHORT).show(); } }); } }); scannerView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mCodeScanner.startPreview(); } });

babakmhz avatar Jan 17 '20 19:01 babakmhz

@babakmhz The same thing happened to me, but in my case in the onResume it sent to call the initialization of the library twice when it asked for the runtime Permissions.

Check that the initialization is not being double called

crismaver1993 avatar Feb 25 '21 12:02 crismaver1993