There is a need to scan the QR code on the project, and the more mature framework is zbar,zxing. But each has the superiority, the individual thinks still is zbar to the scanning package efficiency is relatively higher, at that time I do is scans some zbar, recognizes this map library
There are some zxing, Later found that zbar in the android5.0 above causes the project to crash directly, because of the lack of the cpu64 bit of so file, due to lack of technology to solve the problem, also did not find support 64-bit so file, the last cruel, scan QR code This module all re-do, the reference of the zxing. But later found that the interface of zxing is really ugly, or decided to optimize it.
One
The Zxing jar package is first directed into the project Libs directory, and some associated files under Res are required (Strings.xml,raw under Values Color.xml, Ids.xml, Beep.ogg).
Two
Lead the project into studio,
Three
Modify to vertical screen (refer to other people's methods)
The following code is commented out in the Initfromcameraparameters () method of the 1.CameraConfigurationManager class:
Code snippet, double-click Copy
01 02 03 04 05 06 |
if (width < height) {log.i (TAG, "Display reports portrait orientation; Assuming this is incorrect "); int temp = width; width = height; Height = temp; } |
2. In the Setdesiredcameraparameters () method of the Cameraconfigurationmanager class, add the following code before camera.setparameters (parameters):
Code snippet, double-click Copy
01 |
Camera.setdisplayorientation (90); |
3. Replace the following code in the Getframingrectinpreview () method of the Cameramanager class:
Code snippet, double-click Copy
01 02 03 04 |
Rect.left = Rect.left * cameraresolution.x/screenresolution.x; Rect.right = Rect.right * cameraresolution.x/screenresolution.x; Rect.top = Rect.top * CAMERARESOLUTION.Y/SCREENRESOLUTION.Y; Rect.bottom = Rect.bottom * CAMERARESOLUTION.Y/SCREENRESOLUTION.Y; |
Replaced by
Code snippet, double-click Copy
01 02 03 04 |
Rect.left = Rect.left * cameraresolution.y/screenresolution.x; Rect.right = Rect.right * cameraresolution.y/screenresolution.x; Rect.top = Rect.top * CAMERARESOLUTION.X/SCREENRESOLUTION.Y; |