I am trying to edit the Ocr project here
https://github.com/googlesamples/android-vision/tree/master/visionSamples/ocr-codelab/ocr-reader-complete
I want to send the string to OcrCaptureActivity.java if it is work.
In OcrDetectorProcess.java (Original)
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    graphicOverlay.clear();
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        if (item != null && item.getValue() != null) {
            Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue());
            OcrGraphic graphic = new OcrGraphic(graphicOverlay, item);
            graphicOverlay.add(graphic);
        }
    }
}
I changed OcrDetectorProcessor.java
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    graphicOverlay.clear();
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);
        if (item != null && item.getValue() != null) {
            Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue());
            OcrGraphic graphic = new OcrGraphic(graphicOverlay, item);
            graphicOverlay.add(graphic);
        }
    }
    OcrCaptureActivity ocrCaptureActivity = new OcrCaptureActivity();
    ocrCaptureActivity.printtext();
}
I added this code in OcrCaptureActivity.java
public void printtext() {
     textView = findViewById(R.id.resulttext);
    textView.post(new Runnable() {
        @Override
        public void run() {
            textView.setText("fdsfsdfsdf");
        }
    });
}
But the error message was shown as below
java.lang.RuntimeException: Can't create handler inside thread Thread[Thread-6,5,main] that has not called Looper.prepare()
 
    