barcodescanner-lib-aar icon indicating copy to clipboard operation
barcodescanner-lib-aar copied to clipboard

BackPressed issue

Open vlazar83 opened this issue 5 years ago • 0 comments

Hi Folks,

when the user clicks the back button on the barcode scanning screen, the onKeyDown (in CaptureActivity) will react to it and the activity will be closed. But the next Activity will capture the onBackPressed event, therefore it will be closed as well. So with one back click, 2 Activity are closed.

With this modification we get the expected result: So we handle the exit on the onBackPressed and not on the onKeyDown:

@Override public void onBackPressed() { if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED); finish(); } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); } super.onBackPressed(); }

@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { /* case KeyEvent.KEYCODE_BACK: if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED); finish(); return true; } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } break;*/ case KeyEvent.KEYCODE_FOCUS:

vlazar83 avatar Mar 27 '19 12:03 vlazar83