Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackPressed issue #24

Open
vlazar83 opened this issue Mar 27, 2019 · 0 comments
Open

BackPressed issue #24

vlazar83 opened this issue Mar 27, 2019 · 0 comments

Comments

@vlazar83
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant