Zxing doesn't exit after successful scan

285 views
Skip to first unread message

Max Ime

unread,
Sep 4, 2013, 12:51:16 AM9/4/13
to zx...@googlegroups.com
I have read a lot of similar problems, but none fit my case.

Note: I don't want to use the IntentIntegrator because I don't want to get the google play popup, I already integrated the zxing in my project. 

I am in a background process that has been started from my main activity. In another activity (that runs in its own process) I click on a scan button. This button will then trig the scan through the service and the service will then handle the result.

Everything is working fine (I use an AIDL file for inter process comm) but after the scanner has successfully scanned it shows the result in the zxing view (overlays it with my scanned image and info) but it doesn't call onActivityResult. It just stays there.

Here is my code:
First the service starts a "wrapper" activity (because I can't call startActivityForResult

 Log.d(TAG, "activate native camera");
 Intent barcodeScannerIntent = new Intent("xxx.android.service.DoryBarcodeScanner");
 barcodeScannerIntent.addCategory(Intent.CATEGORY_DEFAULT);
 barcodeScannerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 service.getApplicationContext().startActivity(barcodeScannerIntent);

Then in that activity I call the scan:

 public void scan() {
  Log.i(TAG, "scanning with intent " + SCAN_INTENT);
  Intent intentScan = new Intent(SCAN_INTENT);
  intentScan.addCategory(Intent.CATEGORY_DEFAULT);
  intentScan.putExtra("SCAN_MODE", "ONE_D_MODE"); 
         
  Log.i(TAG, "start activityForResult with request code " + REQUEST_CODE);
  startActivityForResult(intentScan, REQUEST_CODE);
 }

 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   Log.i(TAG, "we got a result for activity with code:" + requestCode);
   if (requestCode == REQUEST_CODE) {
    if (resultCode == Activity.RESULT_OK) {
      String result = intent.getStringExtra("SCAN_RESULT");
      String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
      Log.i(TAG, "we got a camera scan: " + result);
      // service.handleScan(result);
      this.finish();
    }
   }
 }

What can I do so that the scanner exits after a scan?

Sean Owen

unread,
Sep 4, 2013, 3:11:46 AM9/4/13
to zx...@googlegroups.com
Sounds like you're using your own modification, and presumably the problem is with your modification. I don't see why you're both using Intents and trying to embed the code -- these don't go together. 

Please note the following warnings and restrictions when copying the android/ code: https://code.google.com/p/zxing/wiki/LicenseQuestions

This is one of the main reasons you use the main app by Intent -- because it's hard for any but seasoned developers to get right.
This is also why we discourage embedding -- when it doesn't work it generates support questions that aren't really our problem.
Reply all
Reply to author
Forward
0 new messages