1

I am integrating the zxing library to scan the barcode to my android app. I am doing this local to my application as illustrated in

http://code.google.com/p/zxing/source/browse/trunk/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java

But while running the app, it asks me to install the Barcode scanner app. Is it not possible to achieve this without installing of the app?

I have done a lot of research on how to achieve this, but I could not end up with satisfactory results.

I am trying to do this using this piece of code,

      IntentIntegrator integrator = new IntentIntegrator(TestActivity.this);
      integrator.addExtra("SCAN_WIDTH", 800);
      integrator.addExtra("SCAN_HEIGHT", 200);
      integrator.addExtra("RESULT_DISPLAY_DURATION_MS", 3000L);
      integrator.addExtra("PROMPT_MESSAGE", "Custom prompt to scan a product");
      integrator.initiateScan(IntentIntegrator.PRODUCT_CODE_TYPES);

Please help me

Update :

I am using a different technique of zxing to scan now i.e. to capture image with the camera and then decoding it. I am able to capture the image with this code, but after capturing, I am trying to decode the bitmap of captured image using LuminanceSource, RGBLuminanceSource etc classes.

But the resulting binarybitmap,

    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

appears to be null.

Can anybody tell me why is this? I have seen many posts saying that is is working for them but it is not working for me.

Can anybody please suggest me something.

Here is the link I referred, I am using the exact code in the accepted answer

Barcode/Qr Code Reader for Android

Community
  • 1
  • 1
tejas
  • 2,435
  • 10
  • 37
  • 54
  • possible duplicate of [Embed Zxing library without using Barcode Scanner app](http://stackoverflow.com/questions/4854442/embed-zxing-library-without-using-barcode-scanner-app) – Sean Owen Feb 11 '13 at 08:19
  • I came to know about the other question only after seeing your comment. Even then, I haven't got what is conclusion. Is it not possible? – tejas Feb 11 '13 at 10:31
  • I had this exact same issue. Check out my answer here http://stackoverflow.com/questions/14861553/zxing-convert-bitmap-to-binarybitmap – Jameo Feb 18 '13 at 15:58
  • @Jameo, thank you for responding. I will check this – tejas Feb 19 '13 at 07:31
  • Basically, with a few intermediary steps, (also with core.jar imported), you can take a bitmap and decode it. Note that you probably want to crop the bitmap if it of high resultion – Jameo Feb 19 '13 at 13:55
  • first answered here, then moved my answer over to: https://stackoverflow.com/a/46302841/549372 – Martin Zeitler Sep 19 '17 at 14:18

3 Answers3

1

You should get all the code including zXing library(core.jar) you can download from Google code hosting and then modify CaptureActivity.class for returning result to your previous activity. call intent

   Intent ii=new Intent(your activity.this,CaptureActivity.class);
    startActivityForResult(ii);

then define onActivityForResult where you will have corresponding result.

Krishna Shrestha
  • 1,662
  • 14
  • 38
  • why CaptureActivity? Is it not possible with IntentIntegrator as per the example they have given in ZXingTestActivity.java. I do not want it force me to install a barcode scanner app. That is where I am facing the issue – tejas Feb 11 '13 at 08:00
  • example provided cant solve your problem. intent Integrator assume there should be Zxing barcode scanner app otherwise it force to install app.and on your case you need barcode scanner with in your app isn't it? – Krishna Shrestha Feb 11 '13 at 08:14
  • yes exactly, it is asking me to install the scanner app. Then what is the solution for this? But in iPhone I think it is possible using the same Zxing. then it should be possible in android also right? – tejas Feb 11 '13 at 08:54
  • Oh I'm sorry iPhone app uses some other sdk something called scanned sdk – tejas Feb 11 '13 at 09:07
1

Finally I have found the answer for this. Using IntentIntegrator will ask you to install the scanner app manually and then will scan barcode using that.

So, whoever do not want to use neither the app or the intent call can use one more activity provided in the library called CaptureActivity

    Intent intent = new Intent(MyActivity.this, CaptureActivity.class);
    startActivityForResult(intent, 1);

This class is present in android folder of Zxing library which you have downloaded. Importing this android project into your application will integrate the Zxing library. Be careful about package names while importing.

You can modify CaptureActivity according to your needs

Note:

It is very important to add core.jar or else you will be ending up with lot of errors.

tejas
  • 2,435
  • 10
  • 37
  • 54
-1

I haven't used zxing library but used biggu Barcode Scanner for my apps. It also internally uses the same zxing library but was customized making integration process very easy. Check my Answer here it might help you integrating the Barcode scanner. You can also refer the accepted answer in the same link if you are interested in scanning Barcode by decoding the image.

Community
  • 1
  • 1
TNR
  • 5,839
  • 3
  • 33
  • 62
  • thank you for responding. But in the accepted answer what happens on capturing the image? I am supposed to use only Zxing and that too IntentIntegrator. – tejas Feb 11 '13 at 07:57
  • @tejas in the accepted answer it takes the image and then decodes that image. I can suggest you to use Biggu Barcode Scanner it will be same as zxing library – TNR Feb 11 '13 at 08:08
  • oh is it? I think then it is not the straight approach. No, @TNR, it is not in my hand to change the scanner, hope you got it :( – tejas Feb 11 '13 at 08:57