Integrate the default QR Code scan page

Source: Internet
Author: User

1. Perform the compile operation in the module's Build.gradle

Compile ' cn.yipianfengye.android:zxing-library:2.2 '

2. Perform initialization in demo application

@Override      Public void onCreate () {        super. OnCreate ();        Zxinglibrary.initdisplayopinion (this);    }

3. Perform open scan QR code interface operation

  New Intent (mainactivity.  this, captureactivity. class );  Startactivityforresult (Intent, Request_code);
The request_code here is our definition of the INT type constant

4. Receive the scan results in the activity's Onactivityresult method

/*** 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); Toast.maketext ( This, "Parse Result:" +result, Toast.length_long). Show (); } Else if(Bundle.getint (codeutils.result_type) = =codeutils.result_failed) {Toast.maketext (mainactivity). This, "Parsing the QR code failed", Toast.length_long). Show (); }            }        }

Integrate the default QR Code scan page

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.