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