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 <jouni@codeaurora.org>
This commit is contained in:
parent
be97da671c
commit
ba5498d207
1 changed files with 8 additions and 1 deletions
|
@ -35,6 +35,9 @@ public class QrCodeScannerActivity extends Activity {
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(ACTION);
|
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 {
|
try {
|
||||||
startActivityForResult(intent, QRCODE);
|
startActivityForResult(intent, QRCODE);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
|
@ -46,8 +49,12 @@ public class QrCodeScannerActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + " resultCode=" + resultCode);
|
||||||
if (requestCode == QRCODE && resultCode == RESULT_OK) {
|
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();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue