From ba5498d2078bf524b73e97ee5bb3bd9d1ed183ee Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 23 Feb 2018 16:29:05 +0200 Subject: [PATCH] wpadebug: Improve QR Code scanning with zxing Set SCAN_MODE to accept only QR Codes and close the scanner more reliably after a successfully scanned QR Code. Signed-off-by: Jouni Malinen --- wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java b/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java index 0c31553e7..4b3591c72 100644 --- a/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java +++ b/wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java @@ -35,6 +35,9 @@ public class QrCodeScannerActivity extends Activity { Intent intent = new Intent(); intent.setAction(ACTION); + intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); + intent.putExtra("PROMPT_MESSAGE", + "Place a QR Code inside the viewfinder rectangle to scan it."); try { startActivityForResult(intent, QRCODE); } catch (ActivityNotFoundException e) { @@ -46,8 +49,12 @@ public class QrCodeScannerActivity extends Activity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { + Log.d(TAG, "onActivityResult: requestCode=" + requestCode + " resultCode=" + resultCode); if (requestCode == QRCODE && resultCode == RESULT_OK) { - writeToFile(data.getStringExtra(RESULT)); + String contents = data.getStringExtra(RESULT); + writeToFile(contents); + Log.d(TAG, "onActivityResult: QRCODE RESULT_OK: " + contents); + finishActivity(requestCode); finish(); } }