Android Application using Another Applicatione.g. Using ZXING Android BarCode Scanner Application as an INTENT in YOUR own Android Application
STEP 1: Download 3rd party application (i.e. barcode scanner) to your device (or machine you have emulator on)
ExampleTo download ZXing app:
STEP 2: Get or create code to "communicate" with the 3rd party Application
General Idea
Example 3rd Party App = ZXing Barcode ApplicationTo download the ZXing library: http://code.google.com/p/zxing/downloads/detail?name=ZXing-1.7.zip (local copy) CONTENTS includes:
Explanation of the Application that uses the ZXING barcode app to do Search in Google and Amazon(VIDEO DEMOING INTEGRATION OF ZXING) (VIDEO DEMOING INSTALL OF AN APK ONTO A PHSICAL DEVICE)
How ZXING WORKS (basically) TO GET BAR CODEStage1: invoke the camera of the phone using an intent. Stage 2: Convert the captured image into a bitmap. Stage 3: Use Non-Determinism (of efficiently by using Hints) to determine the format of the barcode. Stage 4: Use the pertinent barcode reader to decode the information encoded in the barcode by adhering to the protocol of the corresponding barcode. Stage 5: deliver the encoded information, barcode format to the calling function.
Instantiate a readerWe first need to instantiate a reader to establish the type of code we intend our application to read and decode. For generic applications there is a comprehensive code decoder that we could instantiate and deploy.
The variable reader is of type Reader that is a user defined type. Or if we want our application to be more specific in purpose (i.e. if we develop an application to read only a certain type of barcode, we use the other readers provided in the library) The other readers include
ZXING captures imagecapture an image by invoking an intent to the phone’s camera To invoke the phone’s camera (upon an event like the click of a button) ...read ZXING code (go on web) for actual details
ZXing must get Image for processing ...here I am showing it saved to local bmp file (here called data)
ZXING must now perform Image Processing and Recognition to Detect the Barcode(see ZXING code for actual implementation) The bitmap of the image captured is provided as a parameter to the Reader (interface) that returns the decoded information from the bitmap. In the Result class, the Barcode format is non deterministically obtained by testing out all the supported barcode formats. In other cases, the Result class also takes in “Hints” as parameters to efficiently cut down on the format determination time by passing in the format of the pertinent barcode. Going ahead I am elaborating on the retrieval of the information of a EAN13 code. (The decoding of different types of barcodes needs to follow different protocols as indicated by the same) For an EAN-13 barcode, the first digit is represented by the parities used to encode the next six digits, according to the table below. For example, if the barcode is 5 123456 789012 then the value of the first digit is signified by using odd for '1', even for '2', even for '3', odd for '4', odd for '5', and even for '6'. // Parity of next 6 digits Digit 0 1 2 3 4 5
0 Odd Odd Odd Odd Odd Odd
1 Odd Odd Even Odd Even Even
2 Odd Odd Even Even Odd Even
3 Odd Odd Even Even Even Odd
4 Odd Even Odd Odd Even Even
5 Odd Even Even Odd Odd Even
6 Odd Even Even Even Odd Odd
7 Odd Even Odd Even Odd Even
8 Odd Even Odd Even Even Odd
9 Odd Even Even Odd Even Odd
The encoding is represented by the following array, which is a bit pattern using Odd = 0 and Even = 1. For example, 5 is represented by: Odd Even Even Odd Odd Even in binary: 0 1 1 0 0 1 == 0x19 Based on pattern of odd-even ('L' and 'G') patterns used to encode the explicitly-encoded digits in a barcode, determines the implicitly encoded first digit and adds it to the result string. If a string is successfully decoded, it is sent returned to the calling function. The Intent Integrator class that is available as a part of the client project.
Now do a search using Google or Amazon or Yahoo! that accept barcode=**** in the URLWe could then proceed to embed/utilize the barcode information as conceived by the application that we create. |
||||||