Project [2) install and scan the QR code on your mobile phone]

Source: Internet
Author: User


Preface

Series of articles:[Portal]

May 1, two days of vacation. My birthday, happy.

[Tucao]

The school is really disgusting. I asked him to give him something half a month ago. md is not a subject. Later I asked for money (money is not needed; I guess not much ). Now again, I'm dizzy. Simply put, add me to do it. Time problems may be half-finished products. Do not add or do not.

Body

As mentioned aboveQR code generation and Decoding

This time we will use android to scan the QR code.

  

    Download Scan

Package Structure-Introduction

  

# Com. zxing. xx this is provided by the zxing Library

# BarCodeActivity

Practice

One button, one interface for Displaying results

Package sedion. jeffli. activity; import sedion. jeffli. in the left-side navigation pane. r; import com. zxing. activity. captureActivity; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. view; import android. view. view. onClickListener; import android. widget. button; import android. widget. textView; import android. widget. toast; public class BarCodeActivity extends Activity {private TextView resultTextView; // return the displayed result (useless in the future) private Button scanBarCodeButton; @ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. barcode); resultTextView = (TextView) this. findViewById (R. id. TV _scan_result); scanBarCodeButton = (Button) this. findViewById (R. id. btn_scan_barcode); scanBarCodeButton. setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {// open the scan interface Intent openCameraIntent = new Intent (BarCodeActivity. this, CaptureActivity. class); startActivityForResult (openCameraIntent, 0) ;}}) ;}@ Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {super. onActivityResult (requestCode, resultCode, data); // judge the processing result and display if (resultCode = RESULT_ OK) {Bundle bundle = data. getExtras (); String scanResult = bundle. getString ("result"); // Toast. makeText (this, "result", Toast. LENGTH_LONG ). show (); resultTextView. setText (scanResult );}}}

 

# New Intent (BarCodeActivity. this, CaptureActivity. class );

Open the scan page-> CaptureActivity (this is the activity for scanning)

# ResultCode = RESULT_ OK

The result is displayed successfully.

 

You will see:

  

 

The scan page is as follows:

CaptureActivity (provided by the zxing library, nice)

View Code

 

 

You will see:

  

Summary

 Android QR code scan

Resource Sharing:

Link: http://pan.baidu.com/share/link? Required id = 4287950048 & uk = 3307409781 password: 3ur2

Thanks and Resource Sharing

    

One step on the road, I hope everyone will join me.

Thank you! I like your support. I will respect every sentence you say, just as you respect my article.

Knowledge Source: https://github.com/zxing/zxing/wiki/Getting-Started-Developing

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.