{"id":643,"date":"2012-11-27T15:46:02","date_gmt":"2012-11-27T15:46:02","guid":{"rendered":"http:\/\/www.bardecode.com\/en1\/?p=643"},"modified":"2013-02-19T11:13:40","modified_gmt":"2013-02-19T11:13:40","slug":"android-barcode-reading-quick-start-guide","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/en1\/android-barcode-reading-quick-start-guide\/","title":{"rendered":"Android Barcode Reading &#8211; Quick Start Guide"},"content":{"rendered":"<p>So what&#8217;s the easiest way to integrate barcode reading into your app?<\/p>\n<p>Whilst it&#8217;s possible to integrate the Softek Barcode Reader into your Android app through our java class and jni library, it&#8217;s also possible to simply call our Bardecoder app direct from your own app with a minimal amount of work.<\/p>\n<p>The following article describes how to call our Bardecoder Android app from your application, read a barcode and return the barcode value to your own app.<\/p>\n<p><strong>Step 1<\/strong><\/p>\n<p>Download the Bardecoder app to your phone from the Android Market:<\/p>\n<p>https:\/\/market.android.com\/details?id=com.softeksoftware.bardecoder<\/p>\n<p><strong>Step 2:<\/strong><\/p>\n<p>Add the following code to your project where you want to launch the Bardecoder app:<\/p>\n<pre>Intent myIntent; myIntent = new Intent();\r\nmyIntent.setComponent(new ComponentName(\"com.softeksoftware.bardecoder\", \"com.softeksoftware.bardecoder.scanner\"));\r\nmyIntent.putExtra(\"com.softeksoftware.bardecoder.scanner.settings\", \"MY XML SETTINGS - <a href=\"http:\/\/bardecode.com\/en\/knowledge-base\/265-android-barcode-reading-quick-start-guide.html#XMLSETTINGS\">SEE BELOW<\/a>\");\r\nmyIntent.putExtra(\"com.softeksoftware.bardecoder.scanner.finishOnSuccess\", true);\r\nmyIntent.putExtra(\"com.softeksoftware.bardecoder.scanner.vibrateOnSuccess\", true);\r\nmyIntent.putExtra(\"com.softeksoftware.bardecoder.scanner.beepOnSuccess\", true);\r\nmyIntent.putExtra(\"com.softeksoftware.bardecoder.scanner.licenseKey\", \"MY LICENSE KEY - <a href=\"http:\/\/bardecode.com\/en\/LICENSEKEY\">SEE BELOW<\/a>\");\r\ntry {\r\n\tstartActivityForResult(myIntent, 0);\u00a0\r\n}\r\ncatch(ActivityNotFoundException ex) {\r\n\tbardecode.this.t.setText(\"Please install the Bardecoder app on your phone\");\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<div><strong>Step 3:<\/strong><\/div>\n<div>Add the following function to collect the results of the barcode scanning:<\/div>\n<div>public void onActivityResult(int requestCode, int resultCode, Intent data)<\/div>\n<div>{<\/div>\n<div>\u00a0 \u00a0 super.onActivityResult(requestCode, resultCode, data);<\/div>\n<div>\u00a0 \u00a0 if (data != null)<\/div>\n<div>\u00a0 \u00a0 {<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Bundle bundle = data.getExtras();<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ Get the value of the bar-code<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ The bar-code type is also available in the key &#8220;com.softeksoftware.bardecoder.scanner.type&#8221;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 value = bundle.getString(&#8220;com.softeksoftware.bardecoder.scanner.value&#8221;);<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (value != null)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ Do something with value<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 }<\/div>\n<div>\u00a0 \u00a0 }<\/div>\n<div>}<\/div>\n<div><strong><a name=\"XMLSETTINGS\"><\/a>MY XML SETTINGS<\/strong><\/div>\n<div>The XML settings allow you to control features of the barcode reader toolkit such as which barcodes to read. For example, if you want to read QRCodes and DataMatrix barcodes then include the following text in your settings string:<\/div>\n<div>&lt;ReadQRCode&gt;1&lt;\/ReadQRCode&gt;&lt;ReadDataMatrix&gt;1&lt;\/ReadDataMatrix&gt;<\/div>\n<div>Example code:<\/div>\n<div>\n<pre>myIntent.putExtra(\"com.softeksoftware.bardecoder.scanner.settings\", \"&lt;ReadQRCode&gt;1&lt;\/ReadQRCode&gt;&lt;ReadDataMatrix&gt;1&lt;\/ReadDataMatrix&gt;\");<\/pre>\n<\/div>\n<div><a href=\"http:\/\/bardecode.com\/download\/barcode_sdk\/android\/manual.pdf\">Download the manual<\/a>\u00a0to get the full list of properties that can be set in this way.<\/div>\n<p>&nbsp;<\/p>\n<div><strong><a name=\"LICENSEKEY\"><\/a>MY LICENSE KEY<\/strong><\/div>\n<div>You can get a free 30-day license key for the SDK by emailing\u00a0<a href=\"mailto:sales@bardecode.com\">sales@bardecode.com<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>So what&#8217;s the easiest way to integrate barcode reading into your app? Whilst it&#8217;s possible to integrate the Softek Barcode Reader into your Android app through our java class and jni library, it&#8217;s also possible to simply call our Bardecoder app direct from your own app with a minimal amount of work. The following article<\/p>\n<p><a href=\"https:\/\/www.bardecode.com\/en1\/android-barcode-reading-quick-start-guide\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":324,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[170,171,140,19,172,173,65,62],"class_list":["post-643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development-kits","tag-android-2","tag-app","tag-application","tag-barcode","tag-htc","tag-samsung","tag-sdk-2","tag-software"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/643"}],"collection":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/comments?post=643"}],"version-history":[{"count":4,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":1552,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/643\/revisions\/1552"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media\/324"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media?parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/categories?post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/tags?post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}