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..
Related
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.
I'm writing an app that uses the camera. I want to lauch an intent to allow users to annotate the resulting image with lines and text, AND I would like to provide the user with a list of appropriate image editting apps they can use, but I'm coming across these problems:
1. Not all image editting apps appear in the list when I perform this code:
editIntent = new Intent();
editIntent.setAction(Intent.ACTION_EDIT);
Uri imageToEditUri = selectedPhotoLocation; // Uri of existing photo
String imageToEditMimeType = "image/*";
editIntent.setDataAndType(imageToEditUri, imageToEditMimeType);
startActivityForResult(Intent.createChooser(editIntent,"Edit Image"), IMPLICIT_EDIT_IMAGE);
Is there a way to get a list of apps that will respond to Intent.ACTION_EDIT?
2. PS Express is the only app I've found that returns the Uri of the editted image in the data.getDate() Uri returned to OnActivityResult(), with other apps the user is forced to save, remember the location, and reselect the editted image.
Is there a way to know what apps return the Uri of the image to OnActivityResult()
Not all image editting apps appear in the list when I perform this code
Just because an app implements image editing does not necessarily mean that it is set up to allow third parties to link to their image-editing activities.
Is there a way to get a list of apps that will respond to Intent.ACTION_EDIT?
If you mean that you want to do this programmatically at runtime, see Jedil's answer.
Is there a way to know what apps return the Uri of the image to OnActivityResult()
No, except for those applications that have documentation on how developers should integrate with them.
First question answer:
try queryIntentActivities
Intent editIntent = new Intent(android.content.Intent.ACTION_EDIT);
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(editIntent, 0);
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");
I have downloaded the zxing 1.6 and was able to successfully run a standalone barcode scanner through it. Now this scanner is in another project and (the CaptureActivity) and I have my app's different project called MyProj , all I
want to do is on click of button in my project call CaptureActivity in another project , how do I import that entire project in my project or what do I do it get this working.
Thanking in advance
I think that "copying" Barcode Scanner and include it in your app might be overloading your projects. You should certainly use the Intent from the Scanner:
From here: http://code.google.com/p/zxing/wiki/ScanningViaIntent
If the Barcode Scanner is installed on your Android device, you can have it scan for you and return the result, just by sending it an Intent. For example, you can hook up a button to scan a QR code like this:
public Button.OnClickListener mScan = new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.setPackage("com.google.zxing.client.android");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
};
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");
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
For more options, like scanning a product barcode, or asking Barcode Scanner to encode and display a barcode for you, see this source file:
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/Intents.java
And here's some source from our test app which shows how to use them:
http://code.google.com/p/zxing/source/browse/trunk/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java
IntentIntegrator
We have also begun creating a small library of classes that encapsulate some of the details above. See IntentIntegrator for a possibly easier way to integrate. In particular this will handle the case where Barcode Scanner is not yet installed.
http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java
Via URL
As of Barcode Scanner v2.6, you can also launch the app from a URL in the Browser. Simple create a hyperlink to http://zxing.appspot.com/scan and Barcode Scanner will offer to launch to handle it. Users can also choose to always have Barcode Scanner open automatically.
NOTE: This URL is not meant to serve an actual web page in a browser, it's just a hook to launch a native app.
Known Issues
User jamesikanos reports the following 'gotcha':
Create a TabHost activity with launchMode "singleInstance"
Create a child activity with a "Start scan" button (launch zxing using the IntentIntegrator from this button)
onActivityResult in your child activity will return immediately as "cancelled"
onActivityResult is never called subsequently
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 )