Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Finish ZBar Scanner after result is passed
    primarykey
    data
    text
    <p>I have an activity, called ScanRouter, that calls ZBar Scanner via startActivityForResult. Once I scan a code, onActivityResult in ScanRouter processes the result, passes the result to another activity via intents and ScanRouter is "finish()".</p> <p>However, after the result is passed to the new activity, if the back button is pressed, ScanRouter reopens ZBar. If I set ScanRouter to noHistory=true, then onActivityResult doesn't work.</p> <p>How can I prevent ScanRouter from firing again if the back button is pressed? I thought finish() would remove it from the stack but that is apparently not true. I would like to go back to the activity that originally called ScanRouter rather than ScanRouter itself.</p> <p>ScanRouter: Portion of the code that matters</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ZBAR_SCANNER_REQUEST: case ZBAR_QR_SCANNER_REQUEST: if (resultCode == RESULT_OK) { // TODO go back to the caller and give them the result String value = data.getStringExtra(ZBarConstants.SCAN_RESULT); **returnIntent(value);** } else if(resultCode == RESULT_CANCELED &amp;&amp; data != null) { // TODO go back to the caller and give them the error String error = data.getStringExtra(ZBarConstants.ERROR_INFO); if(!TextUtils.isEmpty(error)) { Toast.makeText(this, error, Toast.LENGTH_SHORT).show(); } } break; } } protected void returnIntent(String value) { Intent intent = new Intent(this, Manager.class); intent.putExtra("operation", caller); intent.putExtra("code", value); startActivity(intent); **this.finish();** } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload