Git Product home page Git Product logo

zxingsimple's Introduction

ZXingSimple

ZXing Simplified example for Android.

Using the latest source of 2013-04-25.

Capture

Intent intent = new Intent(this, CaptureActivity.class);
intent.setAction(Intents.Scan.ACTION);
/*intent.putExtra(Intents.Scan.WIDTH, 400);
intent.putExtra(Intents.Scan.HEIGHT, 300);*/
startActivityForResult(intent, REQ_CAPTURE);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQ_CAPTURE) {
        if (resultCode == RESULT_OK) {
            String result = data.getStringExtra(Intents.Scan.RESULT);
            ParsedResultType type = ParsedResultType.values()[data.getIntExtra(
                    Intents.Scan.RESULT_TYPE, ParsedResultType.TEXT.ordinal())];
            String format = data.getStringExtra(Intents.Scan.RESULT_FORMAT);
            byte[] rawBytes = data.getByteArrayExtra(Intents.Scan.RESULT_BYTES);

            Bitmap bm = BitmapFactory.decodeByteArray(rawBytes, 0, rawBytes.length);
            // TODO
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

Generate

Intent intent = new Intent(Intents.Encode.ACTION);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
/** Contents.Type comments for details */
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
try {
    QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(this, intent, dimension, false);
    Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
    if (bitmap == null) {
        Log.w(TAG, "Could not encode barcode");
        Toast.makeText(this, R.string.msg_encode_contents_failed, Toast.LENGTH_SHORT)
                .show();
    } else {
        String title = qrCodeEncoder.getTitle();
        String contents = qrCodeEncoder.getContents();
        // TODO
    }
} catch (WriterException e) {
    e.printStackTrace();
}

Portrait mode

android:screenOrientation="portrait"

Search file for key words Modified for portrait.

zxingsimple's People

Contributors

joinaero avatar

Watchers

 avatar  avatar  avatar

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.