-1

I have used a solution from the SO accepted answer here. It works well inside an Activity but when I implement it inside a Fragment, I got the following error:

Exception thrown from receiver.java.lang.ClassCastException: com.example.app.MainActivity cannot be cast to com.example.app.QRCodeDetectedInterface at com.example.app.BarcodeGraphic.(OcrGraphic.java:54) at com.example.app.OcrDetectorProcessor.receiveDetections(OcrDetectorProcessor.java:49)

It seems there is a problem implementing the interface inside the Fragment. How to overcome this error?

Benjamin
  • 7,055
  • 6
  • 40
  • 60
user1090751
  • 336
  • 1
  • 11

1 Answers1

1

In link you provided BarcodeCaptureActivity listens to events. In your case, as exception suggests, MainActivity listens to events. Your com.example.app.MainActivity must implement com.example.app.QRCodeDetectedInterface.

Stasys Skliutas
  • 230
  • 1
  • 6