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
Related
I have heard that the easiest way to implement ZXing barcode scanner into your own app is with an intent. However, nobody has explained how to do this in Android Studio. There's explanations for how to do it in Eclipse and Maven, but not Android Studio. Do I need to download anything other than the ZXing barcode scanner app, to implement it via intent? I think intents just call another app, but I'm not completely sure. Do I need to download a dependency (such as an AAR, JAR, or JAVA file) to get the ZXing intent to be accessible to an app? Please let me know how to use INTENTS with ANDROID STUDIO, in such a manner as to make it possible for the app I'm writing to use ZXing as its barcode scanner.
You can use ZXing in you app via gradle dependency . Add the following dependencies to your gradle file
compile 'com.journeyapps:zxing-android-embedded:3.1.0#aar'
compile 'com.google.zxing:core:3.2.0'
Then on your activity's onCreate method , add the following
IntentIntegrator scanIntegrator = new IntentIntegrator(MainActivity.this);
scanIntegrator.setPrompt("Scan a barcode");
scanIntegrator.setBeepEnabled(true);
scanIntegrator.setOrientationLocked(true);
scanIntegrator.setBarcodeImageEnabled(true);
scanIntegrator.initiateScan();
This will start a the scanner when you launch the Activity .
You can get the scan result , in onActivityResult
#Override
protected void onActivityResult(final int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
/*As an example in order to get the content of what is scanned you can do the following*/
String scanContent = scanningResult.getContents().toString();
}
You can Develop your own Bar-Code Scanner App: Try this references,
This is ZXing Jar Download Link: http://www.java2s.com/Code/Jar/z/Downloadzxingjar.htm
This is ZXing used to implement Barcode Scanner Reference Link: http://khurram2java.blogspot.in/
I need my app to read text via Camera. I know there's the Tesseract library which does this, but I'd really prefer if there was an app that can handle Intents to read text via Camera, like Xzing does for reading QR codes.
Is there such an app?
There isn't currently an app on Google Play that does this.
I've thought about making one, but the possible use cases for such an app vary much more than for, say, scanning a QR code. There are different possible scenarios:
License plate recognition
Recognition for LCD 7-segment displays
Korean OCR
OCR for stylized text
OCR with shadows or uneven illumination
The different scenarios present a challenge for how to handle the image. A request to such an app via Intent would probably need to specify at least the type of thresholding to use for pre-processing the image along with the language/traineddata file to use.
I've just created an app that takes a photo using the Camera, crop the photo, and return the recognized text as result.
In your app, you may use the following code:
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo("sunbulmh.ocr", PackageManager.GET_ACTIVITIES);
Intent LaunchIntent = pm.getLaunchIntentForPackage("sunbulmh.ocr");
LaunchIntent.setFlags(0);
startActivityForResult(LaunchIntent,5);
} catch (NameNotFoundException e) {
Uri URLURI = Uri.parse("http://play.google.com/store/apps/details?id=sunbulmh.ocr");
Intent intent = new Intent(Intent.ACTION_VIEW,URLURI);
startActivity(intent);
}
Then, get the result in onActivityResult():
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if(requestCode == 5){
String ocr_txt = data.getStringExtra(Intent.EXTRA_TEXT);
// ocr_txt contains the recognized text.
}
}
}
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..
I have posted a question before and got response regarding Barcode scanning in ZXing.
Currently i have run the barcode scanner app code, that is given in the source(/android/) using this post
My objective is to scan a barcode in my app. Since zxing is open source as told by the authors, i need to customize the scanner app raw code in my app. I found many files like WifiActivity and all. I dont know whether all the files are required to scan a barcode.
Now i want to extract the necessary and required files to decode using the camera captured image. Is it possible to extract the parts? If yes, can anyone help me in doing this by referring any links or steps. Thanks for all your useful posts and great responses. Sorry for my bad english.
what exactly are you trying to achieve? Do you want to edit and enhance the ZXing Source/App or want to use this library in your App for scanning.
For scanning you could invoke the activity for the scan result like following:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
try {
startActivityForResult(intent, REQUEST_CODE);
} catch (ActivityNotFoundException e) {
//Do something here
}
After scan u will receive the result in onActivityResult method:
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_CODE) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
I did something similar to this, but I only wanted the QR generation part of the zxing project. So I found the relevant call (maybe something like Bitmap b = zx.genQRCode() or whatever) and copied that java file into my project.
Compile and BAM - you get a ton of compile errors. At the point you just start copying other referenced files into your project until you don't get any more compile errors.
Don't forget to include proper attribution in your app - see this FAQ.
I am trying to use this 3rd Party Signature Capture Android Application with my PhoneGap Application. I have no idea how to "Call the right Activity" from my PhoneGap App. My Application is written in html and javascript.
Please help!
I have installed the application on my Droid X and it Captures my Signature with my finger. Its super smooth and quick.
http://www.binarysolutions.biz/
Here are the instructions from their website. They are not very detailed.
String key = ""; // set the key, any string you find suitable
String fileName = ""; // set the file name (global write permissions)
Intent intent = new Intent("biz.binarysolutions.signature.CAPTURE");
intent.putExtra(key, fileName);
intent.setComponent(
new ComponentName(
"biz.binarysolutions.signature",
"biz.binarysolutions.signature.Capture"
)
);
startActivityForResult(intent, CAPTURE_REQUEST_CODE);
Receiving the result
#Override
protected void onActivityResult
(
int requestCode,
int resultCode,
Intent data
) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAPTURE_REQUEST_CODE &&
resultCode == RESULT_OK) {
String fileName = ""; // the same file name as above
Bitmap bitmap = BitmapFactory.decodeFile(fileName);
// do with bitmap whatever you like
}
}
The integration of the signature application is doable via an Android Intent to invoke the signature app. Looks like you have the instructions for what you need to do on the Java (native) side to integrate with the signature application, but you are at a loss to do so inside a PhoneGap Android app.
Take a look at WebIntent. It is a PhoneGap Android plug-in - this is an extension to the PhoneGap API and is composed of a small JavaScript interface which your PhoneGap app uses, and a native (Java) component that the JS interface talks to. The WebIntent blog post linked above actually does a pretty good job of explaining a PhoneGap plug-in, too.
What you'll have to do on top of integrating the WebIntent plug-in is interfacing the WebIntent with the Signature app - so the intents getting passed around on the native side contain the proper parameters.
Starting from version 2.5 Signature Capture library can be started from the web browser just by clicking on a specific link. It can also 'upload' captured image to given url. Check out the instructions here:
http://www.binarysolutions.biz/2010/12/signature-capture-for-android.html#usage_web
Hope that could help.