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
-
2is there a generic meme-like type i can call for "barcode scanning"? this intent explicitly specifies the zxing app. – omni May 11 '12 at 10:08
-
`com.google.zxing.client.android.SCAN` is the generic `Intent` for scanning. It's just that ZXing has been around since before Android 1.0 so it's the de facto standard. It does not only select Barcode Scanner. – Sean Owen May 11 '12 at 12:48
1 Answers
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:
And here's some source from our test app which shows how to use them:
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.
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

- 39,407
- 49
- 186
- 260
-
2If you start the intent without setting the package you will get your installed default qr code reader (qr druid in my case) or a appchooser dialog if you have more than one – Radon8472 May 21 '15 at 07:14