(1) Download the QR Code library source code
Link: http://pan.baidu.com/s/1pKQyw2n Password: R5BV
When the download is complete, open the folder where you can see the libzxing, and add it to Android Studio, with the following: File------New-----"Import moudle
(2) button click event for scanner
Background code:
Public void Scanner (view view) {
Startactivityforresult (New Intent (Scanactivity.this,
Captureactivity.class), 0);
}
@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
Super.onactivityresult (Requestcode, ResultCode, data);
if (ResultCode = = RESULT_OK) {
Bundle bundle = Data.getextras ();
String result= bundle.getstring ("result");
Etcan.settext (result);
}
}
(3) If continuous scanning is required
Background code:
Link: Http://pan.baidu.com/s/1sle7v4L Password: o85e
Turn on the phone camera scan QR code or barcode all operation