title: Google VISION API read barcode in textview
body: <p>I am trying to integrate Google Vision API in my code but having hard time converting value in to text view. Also the camera surface view doesn't get destroyed. </p>
  
  <p>Manifest Meta-data -</p>
  
  <pre><code>&lt;meta-data
          android:name="com.google.android.gms.vision.DEPENDENCIES"
          android:value="barcode" /&gt;
  </code></pre>
  
  <p>Current Value readed by below code: </p>
  
  <pre><code>com.google.android.gms.vision.barcode.Barcode@eeb8638
  </code></pre>
  
  <p>Expected Barcode Text : <code>047754732276</code></p>
  
  <p>Code:</p>
  
  <pre><code>barcodeDetector =
                  new BarcodeDetector.Builder(transactionActivity)
                          .setBarcodeFormats(Barcode.ALL_FORMATS)
                          .build();
          cameraSource = new CameraSource.Builder(transactionActivity, barcodeDetector)
                  .setAutoFocusEnabled(true)
                  .setRequestedPreviewSize(1600, 1024)
                  .build();
  
          cameraView.getHolder().addCallback(new SurfaceHolder.Callback() {
              @Override
              public void surfaceCreated(SurfaceHolder holder) {
                  try {
                      //noinspection MissingPermission
                      if(ContextCompat.checkSelfPermission(transactionActivity, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
                          ActivityCompat.requestPermissions(transactionActivity, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST);
                      }
                      cameraSource.start(cameraView.getHolder());
                  } catch (IOException ex) {
                      ex.printStackTrace();
                  }
              }
  
              @Override
              public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
              }
  
              @Override
              public void surfaceDestroyed(SurfaceHolder holder) {
                  cameraSource.stop();
              }
          });
          barcodeDetector.setProcessor(new Detector.Processor() {
              @Override
              public void release() {
              }
  
              @Override
              public void receiveDetections(Detector.Detections detections) {
                  final SparseArray barcodes = detections.getDetectedItems();
                  if (barcodes.size() != 0) {
                      imei.post(new Runnable() {
                          @Override
                          public void run() {
                              cameraSource.stop();
                              //Update barcode value to TextView
                              imei.setText(String.valueOf((barcodes.valueAt(0).displayValue)));
                          }
                      });
                  }
              }
          });
  </code></pre>