GithubHelp home page GithubHelp logo

Comments (1)

nusculus avatar nusculus commented on May 29, 2024

While adding the ability to restrict the allowed barcode formats (cuts down on read errors), aside from passing that option thru to zxing, I made these changes in my copy:

Within BarcodeScanner.java
import android.content.ComponentName; // added
private static final String SCAN_INTENT = "com.google.zxing.client.android.SCAN"; // changed
private static final String SCAN_CLASS = "com.google.zxing.client.android.CaptureActivity"; // added
private static final String ENCODE_INTENT = "com.google.zxing.client.android.ENCODE"; // changed
...
Intent intentScan = new Intent(SCAN_INTENT); // same
intentScan.setComponent(new ComponentName(this.cordova.getActivity().getApplicationContext(),SCAN_CLASS));
intentScan.addCategory(Intent.CATEGORY_DEFAULT); // same

in plugin.xml:
action android:name="com.google.zxing.client.android.SCAN"
and
action android:name="com.google.zxing.client.android.ENCODE"

and I restored the action checking code that Eccenux commented out in EncodeActivity.java

The zxing library is looking for the actions "com.google.zxing.client.android.SCAN" and "com.google.zxing.client.android.ENCODE" rather than "com.phonegap.plugins.barcodescanner.SCAN" and "ENCODE". Giving the specific component in the Intent prevents going to other apps that use the same library.

I'm new to plugins and Android. Expect that this can be done better or just plain done right. Please speak up if you see problems with this approach. After some field testing, I'll try to share the restricted format code too.

from barcodescanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.