Skip to content

Commit

Permalink
wpadebug: Improve QR Code scanning with zxing
Browse files Browse the repository at this point in the history
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 <jouni@codeaurora.org>
  • Loading branch information
Jouni Malinen authored and jmalinen committed Feb 23, 2018
1 parent be97da6 commit ba5498d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wpadebug/src/w1/fi/wpadebug/QrCodeScannerActivity.java
Expand Up @@ -35,6 +35,9 @@ protected void onCreate(Bundle savedInstanceState) {

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) {
Expand All @@ -46,8 +49,12 @@ protected void onCreate(Bundle savedInstanceState) {

@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();
}
}
Expand Down

0 comments on commit ba5498d

Please sign in to comment.