Simplified to zxing with only barcode and QR code scanning

Source: Internet
Author: User

Modified based on this source code.

Http://blog.csdn.net/ryantang03/article/details/7831826

 

In addition to the QR code image generation function that he added, the package is saved.

The sound effect after scanning is removed, saving a sound file.

With the flashlight function removed, scan the QR code at night to go to bed quickly. Saves a class.

Scanning timeout is removed, saving two classes.

Removed the title bar of the scan interface, saving an image file.

 

For ease of use, zxing is too troublesome.

The modified code is finally sent.

 

First, copy the file.

1. jar package in the libs folder

2. Four packages except the entry activity

3. layout file camera. xml

4. Value files colors. xml and IDs. xml

In this way, it will be much more troublesome before streamlining.

 

Then we will find many errors, mainly the reference errors of the r class.

In eclipse, press Ctrl + Shift + O to change the r file of your project.

 

Then, the camera and vibration user permissions are added as follows, and users that do not even have the camera are blocked.

<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.VIBRATE" /><uses-feature android:name="android.hardware.camera" /><uses-feature android:name="android.hardware.camera.autofocus" />

 

The scan page captureactivity has not been added to manifest.

<activity    android:name="com.zxing.activity.CaptureActivity"    android:configChanges="orientation|keyboardHidden"    android:screenOrientation="portrait"    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"    android:windowSoftInputMode="stateAlwaysHidden" ></activity>

 

The preparation is complete and you can start using it.

 

Write the onactivityresult method.

Use startactivityforresult to start captureactivity.

Then wait for the result.

 

Get started.

 

Testbarcode.pdf

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.