Close activity after result

1

I'm trying to implement a tutorial using ZXing to read QRCode . In the tutorial that was accompanying it uses the Eclipse and places the libs of ZXing all "by hand" by importing. I'm using Android Studio and I used Gradle to generate the dependencies.

But there comes a point when it edits a lib class of ZXing as it is necessary after taking the QRCode photo to return to ActivityMain to show the result, otherwise it will stop at Activity of the camera.

My questions are:

  • I can not find where Gradle lowers dependencies for me to edit.
  • Is there any other way to make sure that after reading QRcode the Activity %?

Here is the code as implemented.

    
asked by anonymous 12.04.2015 / 22:22

1 answer

1

You do not necessarily need to change the class CaptureActivity , you can create a Activity its that extends from this, and since the change is only in this method, just overwrite it and implement as the tutorial says.

Let's suppose you create this new Activity like this:

public class ScanActivity extends CaptureActivity {
    @Override
    public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
        Intent it = getIntent();
        it.putExtra("SCAN_RESULT", rawResult.getText());
        it.putExtra("SCAN_FORMAT", rawResult.getBarcodeFormat());
        setResult(Activity.RESULT_OK, it);
        finish();
    }
}

So, instead of calling CaptureActivity directly, call this your new ScanActivity :

Intent it = new Intent(MainActivity.this, ScanActivity.class);

Remembering that you should also change the Manifest , as indicated in the tutorial.

    
13.04.2015 / 14:11