KingsMentor / MobileVisionBarcodeScanner

Barcode Scanner powered by Mobile Vision Api
http://belvi.xyz/posts/Mobile-Vision-Barcode-Scanner
MIT License
540 stars 109 forks source link

I have layout in a fragment. The App is crashing with the error log NullException cannot cast to BarcosdeCapture. For activity is working fine but for fragment it is crashing #67

Closed AhmadRehan71 closed 3 years ago

larissayasin commented 4 years ago

I had the same problem. I solved doing this:

private val barcodeCapture by lazy { activity?.supportFragmentManager?.findFragmentById(R.id.qr_code_reader) as? BarcodeCapture }

override fun onCreateView(){
....
  barcodeCapture?.setRetrieval(this@MyFragment)
}