[Thanks for reference]: http://mukeshyadav4u.blogspot.com/2012/06/integrating-zxing-qr-code-scanner-into.html
Using the connection method, I found that no result is returned after the reading is successful, and then I checked the source code. The reason is that captureactivity is forwarded based on the source, set the source action in intent.
Main process:
1. Download zxing source code
Use SVN checkoutHTTP: // Zxing.googlecode.com/svn/trunk/ source code
2. Import the android project to eclipse and mark it as libproject
3. Create your own project and apply libprpoject in Section 2
4. Add the following content to your androidmanifest. xml file:
<activity android:name="com.google.zxing.client.android.CaptureActivity" android:configChanges="orientation|keyboardHidden" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> --> <intent-filter> <action android:name="com.google.zxing.client.android.SCAN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
5. Call the service to read the QR code
I used a button for demonstration.
public void scan(View view){Intent intent = new Intent(this,CaptureActivity.class);intent.setAction(Intents.Scan.ACTION);intent.putExtra(Intents.Scan.MODE, Intents.Scan.QR_CODE_MODE);intent.putExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, 0L);startActivityForResult(intent, 0);}
6. In COM. bbcvison. zxing. test. mainactivity. onactivityresult is used to process the QR code. For the key value of the result of reading the card, see COM. google. zxing. client. android. intents. scan
Attachment: captureactivity.rar is the libprojectcaptureactivitytest.rar generated by me. Thanks again: Thanks again