Android Two-dimensional code

Source: Internet
Author: User

Android-zxinglibrary

Introduction to Framework Features

Easy integration

To open the default QR Code scan page

Support for scanning of picture bitmap

Support for customizing the UI

Supports the scanning function of barcode

Supports generation of QR code operations

Support Control Flash switch

Code section

Integration into the project:

S1. Add dependent compile ' cn.yipianfengye.android:zxing-library:2.2 ' or import library source library;

S2. Initialize Zxinglibrary.initdisplayopinion (this);

S3. Call logger;

API :

Use the default mode

Open the default QR code scanning interface:

Intent Intent = new Intent (Getapplication (), captureactivity.class);

Startactivityforresult (Intent, Request_code);

Accept the result

@Override

protected void Onactivityresult (int requestcode, int resultcode, Intent data) {

/**

* Processing QR Code scan results

*/

if (Requestcode = = Request_code) {

Processing scan results (displayed on the interface)

if (null! = data) {

Bundle bundle = Data.getextras ();

if (bundle = = null) {

Return

}

if (Bundle.getint (codeutils.result_type) = = codeutils.result_success) {

String result = bundle.getstring (codeutils.result_string);

Tvscanmsg.settext (result);

Toast.maketext (This, "parse Result:" + result, Toast.length_long). Show ();

} else if (Bundle.getint (codeutils.result_type) = = codeutils.result_failed) {

Toast.maketext (Mcontext, "Parsing the QR code failed", Toast.length_long). Show ();

}

}

}

}

Custom mode

Add capturefragment Replace scan layout area

Capturefragment = new Capturefragment ();

Set up a custom interface for QR code scanning interface

Codeutils.setfragmentargs (Capturefragment, r.layout.scan_area_layout);

Capturefragment.setanalyzecallback (Analyzecallback);

Getsupportfragmentmanager (). BeginTransaction (). replace (R.id.fl_scan_area, capturefragment). commit ();

Customizing the scan layout

<?xml version= "1.0" encoding= "Utf-8"?>

<framelayout xmlns:android= "Http://schemas.android.com/apk/res/android"

xmlns:app= "Http://schemas.android.com/apk/res-auto"

Android:layout_width= "Fill_parent"

android:layout_height= "Fill_parent" >

<surfaceview

Android:id= "@+id/preview_view"

Android:layout_width= "Wrap_content"

android:layout_height= "Wrap_content"

/>

<com.uuzuche.lib_zxing.view.viewfinderview

Android:id= "@+id/viewfinder_view"

Android:layout_width= "Wrap_content"

android:layout_height= "Wrap_content"

App:inner_width= "200DP"

app:inner_height= "200DP"

app:inner_margintop= "25DP"

App:inner_corner_color= "@color/red"

App:inner_corner_length= "30DP"

App:inner_corner_width= "5DP"

app:inner_scan_bitmap= "@drawable/scan_image"

App:inner_scan_speed= "10"

App:inner_scan_iscircle= "false"

/>

</FrameLayout>

Processing of scan result callbacks

/**

* Two-dimensional code parsing callback function

*/

Codeutils.analyzecallback analyzecallback = new Codeutils.analyzecallback () {

@Override

public void Onanalyzesuccess (Bitmap mbitmap, String result) {

FWLOG.D (result);

Onscanfinish (result);

}

@Override

public void onanalyzefailed () {

FWLOG.D ("Failed ...");

Onscanfinish ("");

}

};

private void Onscanfinish (String result) {

Intent resultintent = new Intent ();

Bundle bundle = new bundle ();

Bundle.putint (Codeutils.result_type, codeutils.result_success);

Bundle.putstring (codeutils.result_string, RESULT);

Resultintent.putextras (bundle);

Setresult (RESULT_OK, resultintent);

Finish ();

}

Support for Custom Scan properties

<declare-styleable name= "Innerrect" >

<attr name= "Inner_width" format= "Dimension"/><!--control the width of the scan box--

<attr name= "Inner_height" format= "Dimension"/><!--control the height of the scan box--

<attr name= "Inner_margintop" format= "Dimension"/><!--control the distance from the top of the scan box--

<attr name= "Inner_corner_color" format= "Color"/><!--control the color of the corners of the sweep box--

<attr name= "Inner_corner_length" format= "Dimension"/><!--control the width of the corners of the sweep box--

<attr name= "Inner_corner_width" format= "Dimension"/><!--control the width of the corners of the sweep box--

<attr name= "Inner_scan_bitmap" format= "reference"/><!--Control scan Graph--

<attr name= "inner_scan_speed" format= "integer"/><!--control scan Speed--

<attr name= "Inner_scan_iscircle" format= "boolean"/><!--controls whether small dots are displayed-

</declare-styleable>

Reference:

Https://github.com/yipianfengye/android-zxingLibrary

Bgaqrcode-android

Introduction to Framework Features

The function is perfect and powerful, not integrated

ZXing Scan two-dimensional code

Image of two-dimensional code in ZXing recognition gallery

Can be set to scan with a front-facing camera

Can control the flash and make it easy to use at night

A wide range of scanning frames can be customized

Customizable full-screen scan or only QR code in scan box area

Zbar Scan two-dimensional code

Code section

Integration into the project:

S1. Add dependent compile ' cn.yipianfengye.android:zxing-library:2.2 ' or import library source library;

S2. Initialize Zxinglibrary.initdisplayopinion (this);

S3. Call logger;

API :

Use the default mode

Open the default QR code scanning interface:

Support for Custom Scan properties

<declare-styleable name= "Innerrect" >

Reference:

Https://github.com/bingoogolapple/BGAQRCode-Android

Zxinggenerator

Effect

Introduction to Framework Features

The fancy QR code is generated and offers 6 different styles. Packaged into a tool class for ease of use.

Code section

Integration into the project:

S1. Adding a dependent zxing jar package;

API :

Tool class

Qrcodeutils

Qrcodeutils.createqrcode ("http://www.tmtpost.com/2536837.html")

Reference:

Vivian8725118/zxinggenerator of 6 styles

Other projects

Google Official program

Https://github.com/zxing/zxing

Another use more, provide several scanning methods, encapsulation is imperfect, need to do some custom modification

https://github.com/journeyapps/zxing-android-embedded

Android Two-dimensional code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.