Scan QR code and display it along with its value - android

I am using Zxing Barcode scanner app to scan bar codes using
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
I could get the result in onActivityResult.I want to display the value of QR code and the QR code itself.
I am unable to figure out how can I scan and capture the image of the QR code at the same time.
Any way to achieve that?

ZXing doesn't actually take a picture when doing scanning. It does "capture" the image off the camera feed, but it doesn't persist anything to the SSD card or memory. You can get at the raw bytes if you're scanning with the IntentIntegrator code they post on their site.
http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java
You can see the IntentResult has the raw bytes. I don't exactly know what format it is in, but I bet you can pass it to Bitmap to get the image.

Related

How to autmatically capture and save image without press capture button in Android?

I am using Android 5.0 to implement an application which allows to automatically capture and save an image into my phone. Currently, I am using bellow code but it requires press the capture button in Capture UI of my phone. Is it possible to capture and save the image without press the capture button? For example, I just call the function myCaptureandSave(), then the phone will display Capture UI and intermediately capture the image and save, I do not need doing more step.
public void myCaptureandSave() {
String image_path = Environment.getExternalStorageDirectory() +"/"+System.currentTimeMillis()+".jpg";
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
//File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File output = new File(image_path);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(output));
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
You have to use Camera Api. Create Service, running in background, which hold reference to this api and current SurfaceTexture, it is necessary, camera will be 'previewing to nowhere'. after that you'll be able to take pictures even if device is locaked
Yes it is possible, but I believe you can't do it using the internal camera (calling the intent). You have to use Camera2 API.
I made a library to use Camera2 API, you can take a look at it if you want:
https://github.com/omaflak/Android-Camera2-Library
In your case, simply pass a dummy SurfaceTexture for the preview and call takePicture().
Hope it will help
how to capture an image in background without using the camera application
i tried with this time ago and with little bit changes i got it.
Hope this helps..

Launch native camera app with option to capture either video or image

I've written an app before where I open the native camera app to capture an image like this:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Or, like this for capturing video:
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
But is there a way to open the native camera app with the option to capture either video or an image? I'd like to open to the image given below, where the user can swipe to access the side-menu and change their input type.
I've tried searching, but no results have come up yet. I'm not sure if there is a way to do this without writing a custom camera implementation, which I'd like to avoid for now.
If this is possible, how can I do it? And how could I go about recognizing what media type the user has chosen once the capture is complete (in onActivityResult, probably)?
Thank you in advance!
Currently As specified by you there are 2 intents for capturing image and video i.e. MediaStore.ACTION_IMAGE_CAPTURE & MediaStore.ACTION_VIDEO_CAPTURElink.
For intially I was also thinking startActivityForResult (Intent intent, int requestCode, Bundle options), Here options param was used to give the extras for the external applications but we can only specify some animations not the values as specified link1 & link2.
Solution
I would rather suggest you to go for the custom app with options as you like rather than the restrictions given by the existing camera app.

QR Code scanning android

I am using Zxing Barcode scanner app to scan bar codes using
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
It works fine. I could get the result in onActivityResult. No problem. I dont want QRCode to be displayed. I mean I don't want to let the end user know the qr code string. But in the history available in the original barcode scanner app, it is showing up the list of QR's scanned. So, how do i make the QRStringfrom my app invisible in History
"SAVE_HISTORY" from package com.google.zxing.client.android.Scan;
/**
* Setting this to false will not save scanned codes in the history.
*/
public static final String SAVE_HISTORY = "SAVE_HISTORY";
Then something like,
intent.putExtra("SAVE_HISTORY", false);
Try this and let me know what happen..

How to get information by bar code?

I'm a new android developer, and I try to create an app for using bar code. I try ZXing, it is very easy. But now I need get information about product by bar code. How can I do that?
You'll need to use some kind of web service to look up the product information associated with an UPC/EAN code using for example an AsyncTask. A quick Google search turned up the Internet UPC Database.
Here's a sample record of what data they provide: http://www.upcdatabase.com/item/0081697521221
Please carefully read their ToS: http://www.upcdatabase.com/docs/terms.asp
To use one dimensional barcodes use PRODUCT_MODE.
If you want to be able to scan them all don't set anything in extras scan_mode.
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.setPackage("com.google.zxing.client.android");
//intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
Bar code gives you nothing but a number (product number). You need to have a web service where you can send this number to get more details.
you have to call the barcode reader by intent, then the user scans the barcode(if they have the barcode reader installed), and the barcode reader sends the data to your app
here's the code on how to do it.
http://code.google.com/p/zxing/wiki/ScanningViaIntent
as you can see in public void onActivityResult
these are the data returned by the scanner
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

ZXing doesn't read 1D barcode in Android app

I am developing a new application which hopefully will use a barcode reader to scan and find books. I will then use the ISBN information to get more information.
The intents work and I can scan 2d barcodes ok but not the 1d barcodes of books which I know scan fine using the full application.
This is my code. I have tried it without putting the intent extras and it doesn't change anything.
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "ONE_D_MODE");
startActivityForResult(intent, 0);
Is there something obvious I am missing? The settings in the app also are selected on 1d scanning only.
Thanks
Turns out that using product mode worked perfectly. I don't know why I didn't try that earlier!
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
(Probably easiest if I answer in just one place: http://code.google.com/p/zxing/issues/detail?id=574 )

Categories

Resources