Giter Club home page Giter Club logo

qrmodule's Introduction

Android QR Module

Download Build Status

  • Thanks to Ryan_Tang.本项目基于他blog上的项目优化改进。
  • Feel free to fork and pr.

Features

  • Qr Scan
  • Qr Generate
QR Scan

Demo APK download or scan

Usage

1 Add gradle dependence:

    compile 'me.ydcool.lib:qrmodule:latest.integration'

2 Add QrScannerActivity to your AndroidManifest.xml

    <activity android:name="me.ydcool.lib.qrmodule.activity.QrScannerActivity"/>

3 Add permissions

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.FLASHLIGHT"/>
    <uses-permission android:name="android.permission.VIBRATE"/>

4 Start QrScannerActivity in your activity.

    Intent intent = new Intent(MainActivity.this, QrScannerActivity.class);
    startActivityForResult(intent, QrScannerActivity.QR_REQUEST_CODE);

5 And receive scanner activity result in your activity.

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == QrScannerActivity.QR_REQUEST_CODE) {
            Log.d(TAG, resultCode == RESULT_OK
                            ? data.getExtras().getString(QrScannerActivity.QR_RESULT_STR)
                            : "Scanned Nothing!");
        }
    }

See more details in Demo MainActivity.

QR Generate

Usage
  • Generate qr code with QrGenerator.
   Bitmap qrCode = new QrGenerator.Builder()
       .content("https://github.com/Ydcool/QrModule")
       .qrSize(300)
       .margin(2)
       .color(Color.BLACK)
       .bgColor(Color.WHITE)
       .ecc(ErrorCorrectionLevel.H)
       .overlay(getContext(),R.mipmap.ic_launcher)
       .overlaySize(100)
       .overlayAlpha(255)
       .overlayXfermode(PortBuff.Mode.SRC_ATOP)
       .encode();

    mImageView.setImageBitmap(qrCode);
Method Description
content(String content) content of qr code.
qrSize(int size) qr code image size.
margin(int margin) default is 2.See more about EncodeHintType.MARGIN
color(int color) qr code foreground color.
color(Context c, @ColorRes int color) set foreground color with color resource.
bgColor(int color) set the background color.
bgColor(Context c,@ColorRes int color) set the background color with color resource.
ecc(ErrorCorrectionLevel e) error correction level , default is L (~7%).See more about ErrorCorrectionLevel.
overlay(Bitmap overlay) overlay image on qr code, usually set with logo. NOTICE: once you set overlay image,you'd better set ecc to H.
overlay(Context c,@DrawableRes int overlay) set overlay with drawable resource.
overlaySize(int size) overlay image size in qr code.
overlayAlpha(int alpha) set overlay image alpha, range [0,255], default is 255(opaque).
overlayXfermode(PorterDuff.Mode m) set xfermode for overlay bitmap,default is SRC,see more about PorterDuff.Mode.
footNote(String s) This feature is under develop .
encode() return a encoded qrCode bitmap.

TODO

  • Custom pattern support.

License

Apache License. See the LICENSE for more info.

qrmodule's People

Contributors

ydcool avatar

Stargazers

 avatar 邵彬 avatar  avatar Dino Priyano avatar hato wang avatar Har Kal avatar Muhammad Islam Taufikurahman avatar Arif R Gilang avatar Berk CAN avatar Kyaw San Oo avatar Juan Diaz avatar  avatar Hangga Aji Sayekti avatar Alter Algo avatar Paul avatar LittleBear123 avatar  avatar Serg Burlaka avatar  avatar Onwa avatar Puri avatar Pablo Rangel avatar Hari Prasad avatar Yen avatar Pranav Lathigara avatar Darshan Mistry avatar SarahCatte avatar ccy joe avatar 快乐小叮当 avatar Vlad avatar  avatar

Watchers

 avatar  avatar

qrmodule's Issues

Progaurd

Where is progaurd rule for QrModule

Not working on marshmallow devices..

I am using that library for scanning the QR code but it's not working on marshmallow devices it's not able to open the camera and showing only black screen. I think because of runtime permission needed in devices greater than version 23.
Please fix it !!
thanks

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.