BarcodeScanner icon indicating copy to clipboard operation
BarcodeScanner copied to clipboard

Back Button Issue on Android

Open joydragon opened this issue 10 years ago • 10 comments

I'm using the plugin on my app and I have the following issue: I have a main page and a button to call the scanner, whenever I press the back button on the emulator and supposedly go back to the main page the back button event is kept fired so I handle it on the main page and the app exits (because of me handling that event there). I'm testing it on the android emulator setting the Virtual Device with the settings as a Nexus 4 with KitKat (4.4.2), and with a Nexus 4 phone as well. The weird thing is that if I tried the same app on a Samsung Galaxy S3 the app doesn't receive that event and it doesn't exit (until you press the back button again).

Thanks

joydragon avatar Mar 10 '14 00:03 joydragon

I have the same issue. When I press back button while scanner is active then backbutton event is somehow fired after scanner dissapears causing my app to go back one screen (or close if it was app's main screen). It only happens on android 4.4.2. On android <= 4.3 all works fine. There's also problem with success callback - it seems like it's not fired at all.

rafalzmuda avatar Apr 28 '14 13:04 rafalzmuda

I was having the exact same issue (Android 4.4.2). I found this link, which has a hack that solves the issue.

http://marsbomber.com/2014/05/29/BarcodeScanner-With-Ionic/

spint002 avatar Jul 16 '14 17:07 spint002

i fix this issue. com.google.zxing.client.android.CaptureActivity.java delete this 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; and add this @Override public boolean onKeyUp(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; } return super.onKeyUp(keyCode, event); }

huangliop avatar Sep 24 '14 09:09 huangliop

Same issue with Android 4.4.4

elmato avatar Nov 21 '14 03:11 elmato

Same on 5.1

peterzebird avatar May 20 '15 13:05 peterzebird

+1 on 4.4.2

fantasybei avatar Jul 07 '15 07:07 fantasybei

Hello, I have the same issue with Android 5.0.2. Interesting to note that this problem does not occur with the Camera plugin.

Thanks!

pierresh avatar Aug 28 '15 16:08 pierresh

+1

javierverb avatar Jan 30 '16 06:01 javierverb

+1

jefferscn avatar Dec 09 '16 06:12 jefferscn

+1

I wonder if a crappy workaround is to put it on a modal, then auto fire the barcode scanner when the modal opens and auto dismisses when the modal barcode scanner completes. Then just pipe the value all the way back then the caller... Will try it out and see if it works.

daniefvh avatar Jul 29 '17 01:07 daniefvh