Android realizes QR code and bar code scanning based on Google zxing, imitating wechat QR code scanning effect (recommended)

I learned about QR code from wechat. At that time, wechat launched QR code scanning function. I felt it was very novel. Scanning a picture could directly add friends. It was incredible. At that time, I didn't know QR code. Hehe, when I was working on a project, the boss said to add QR code scanning function, and then I went to Baidu, Google or something. I found that many friends have the function of introducing QR code scanning. Then I started the QR code scanning function with the introduction of others. With the posts of others, I soon added the function of scanning QR code to my project, and then I was very happy.

With the advent of wechat, QR codes are becoming more and more popular. QR codes can be seen everywhere, such as shopping malls, KFC, restaurants, etc. for QR code scanning, we use Google's open source framework zxing, which we can go to http://code.google.com/p/zxing/ Download the source code and jar package. Previously, the QR code scanning function in my project only realized the scanning function, Its UI is really ugly. For a good application software, its UI interface should also be accepted by the public, otherwise people will not use your software. Therefore, the function and interface of the application software are as important as those of wechat. For example, I believe that wechat UI is imitated by many application software, and I also imitate the effect of wechat scanning QR code, although it is not as exquisite as wechat, But the effect is still OK, so I share the code of modifying UI and scanning QR code with you. First, I will directly copy the same function in my future projects. Second, I will give a reference to people who have not added QR code function and stand on the shoulders of giants. Ha ha, I also added this function on the shoulders of giants before, Next, follow me step by step to realize this function, which removes many unnecessary files

Let's look at the structure of the project first

/** 
 * 处理扫描结果 
 * @param result 
 * @param barcode 
 */ 
public void handleDecode(Result result,Bitmap barcode) { 
 inactivityTimer.onActivity(); 
 playBeepSoundAndVibrate(); 
 String resultString = result.getText(); 
 if (resultString.equals("")) { 
 Toast.makeText(MipcaActivityCapture.this,"Scan Failed!",Toast.LENGTH_SHORT).show(); 
 }else { 
 Intent resultIntent = new Intent(); 
 Bundle bundle = new Bundle(); 
 bundle.putString("result",resultString); 
 bundle.putParcelable("bitmap",barcode); 
 resultIntent.putExtras(bundle); 
 this.setResult(RESULT_OK,resultIntent); 
 } 
 MipcaActivityCapture.this.finish(); 
} 

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>