Scanning barcode from Android application

Today, I was able to do a remarkable task in Android. Actually I have got to read barcode using the android camera. First thing came to my mind was, is it possible? But later after goggling few hours, I found zxing , an open source application for barcode scanning which can be embed into our own application.

My task was to read barcode in a selected textbox. For that I had to do the following thing:

1. I had downloaded and installed BarcodeScanner apk file from here

2. Created an interface with a EditText and a Button

3. On Button click I had to send the intent to the BarcodeScanner

btn_search.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {

        Intent intent = new Intent("");
        intent.putExtra("", "QR_CODE_MODE");
        startActivityForResult(intent, 0);

4. I had placed the Barcode symbol inside the rectangle, given by BarcodeScanner

5.  After scan as it returns to our application, I had to put the barcode number into the EditText, which is done by following code.

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
        } else if (resultCode == RESULT_CANCELED) {
            et_code.setText("Please scan again");

scan a barcode

2 Responses to Scanning barcode from Android application

  1. anyonmys says:

    thanks a lot i was searching for any tutorial to get start……thank a lot again

  2. Pooja says:

    Thank you so much,I think it will be very helpfull to me to start my application.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: