{"id":8019,"date":"2015-11-21T13:38:52","date_gmt":"2015-11-21T13:38:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/21\/android-zxing-barcode-scan-successful-but-not-returning-from-activity-open-source-projects-zxing-zxing\/"},"modified":"2022-08-30T15:03:04","modified_gmt":"2022-08-30T15:03:04","slug":"android-zxing-barcode-scan-successful-but-not-returning-from-activity-open-source-projects-zxing-zxing","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/21\/android-zxing-barcode-scan-successful-but-not-returning-from-activity-open-source-projects-zxing-zxing\/","title":{"rendered":"android: zxing barcode scan successful but not returning from activity-open source projects zxing\/zxing"},"content":{"rendered":"<p>I am successfully using zxing to scan codes, by calling the installed barcode reader&#8217;s intent, but when it beeps and indicates a good scan I expect the zxing activity would return control so I can process the result, but it sits there and tries to scan again. I have to press the back button and <em>then<\/em> it returns and I can do the next step. Is there some obvious flag I&#8217;m missing when I call the scanner?<\/p>\n<p>Any advice gratefully received. Many thanks.<\/p>\n<p>Here&#8217;s my code:<\/p>\n<pre><code>public boolean onTouchEvent(final MotionEvent event) {\n\n    Intent intent = new Intent(\"com.google.zxing.client.android.SCAN\");\n    intent.putExtra(\"com.google.zxing.client.android.SCAN.SCAN_MODE\", \"QR_CODE_MODE\");\n    startActivityForResult(intent, 0);\n\n    return true;\n    }\n\npublic void onActivityResult(int requestCode, int resultCode, Intent intent) {\n\n    super.onActivityResult(requestCode, resultCode, intent);\n\n    if (requestCode == 0) {\n        if (resultCode == RESULT_OK) {\n            String contents = intent.getStringExtra(\"SCAN_RESULT\");\n            String format = intent.getStringExtra(\"SCAN_RESULT_FORMAT\");\n\n            \/\/ Handle successful scan\n\n            String s = \"http:\/\/www.google.com\/search?q=\";\n            s += contents;\n            Intent myIntent1 = new Intent(Intent.ACTION_VIEW, Uri.parse(s));\n            startActivity(myIntent1);\n            }\n        else \n            if (resultCode == RESULT_CANCELED) {\n                \/\/ Handle cancel\n                }\n            }\n        }\n    }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am successfully using zxing to scan codes, by calling the installed barcode reader&#8217;s intent, but when it beeps and indicates a good scan I expect the zxing activity would return control so I can process the result, but it sits there and tries to scan again. I have to press the back button and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8019","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8019"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8019\/revisions"}],"predecessor-version":[{"id":8691,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8019\/revisions\/8691"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}