I\'m writing this in mere desperation :) I\'ve been assigned to make a standalone barcode scanner (as a proof of concept) to an Android 1.6 phone.
For this i\'ve dis
I tried all possible ways to achieve this and then I discovered Minified version of xZing by JourneyApps. I have ported that for eclipse and shared on GitHub.
If you are using eclipse use this project:-
https://github.com/hiteshsahu/XZing-Barcode-Scanner-Minified-Eclipse
If you are using Studio use this project :-
https://github.com/journeyapps/zxing-android-embedded
Advantages
Inbuilt Barcode scanner in your App do not required to install third party apps using playstore.
You dont need to get confused between Core,Android client etc jars simply drop this packages and relevent layouts in your project and you are good to go. Only Jar required is com.google.zxing:core:3.2.0 which you can download from
http://mvnrepository.com/artifact/com.google.zxing/core/3.2.0
No need to add tons of packages see images below for comparison
Before :-
After :-
Most important part is they are highly customizable ie. you can add flash light, use it in fragment and support orientation change.
You can use this Capture activity in Cordova App for barcode scanneing.
your capture activity in app manifest would look like this
and plugin will look like this
public class BarcodeScanner extends CordovaPlugin {
public static final int REQUEST_CODE = 0x0ba7c0de;
private static final String SCAN = "scan";
private static final String CANCELLED = "cancelled";
private static final String FORMAT = "format";
private static final String TEXT = "text";
private static final String SCAN_INTENT = "com.google.zxing.client.android.SCAN";
private static final String LOG_TAG = "BarcodeScanner";
private CallbackContext callbackContext;
/**
* Constructor.
*/
public BarcodeScanner() {
}
/**
* Executes the request.
*
* This method is called from the WebView thread. To do a non-trivial amount of work, use:
* cordova.getThreadPool().execute(runnable);
*
* To run on the UI thread, use:
* cordova.getActivity().runOnUiThread(runnable);
*
* @param action The action to execute.
* @param args The exec() arguments.
* @param callbackContext The callback context used when calling back into JavaScript.
* @return Whether the action was valid.
*
* @sa https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java
*/
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
this.callbackContext = callbackContext;
if (action.equals(SCAN)) {
scan(args);
} else {
return false;
}
return true;
}
/**
* Starts an intent to scan and decode a barcode.
*/
public void scan(JSONArray args) {
Intent intentScan = new Intent(SCAN_INTENT);
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
// add config as intent extras
if(args.length() > 0) {
JSONObject obj;
JSONArray names;
String key;
Object value;
for(int i=0; i
Happy Integration !!