我正在尝试将条形码扫描仪集成到我的android应用程序中。
这些是我所做的事情:
1)我在我的项目中添加了core-3.2.1模块。2)添加了一个活动
<uses-permission android:name="android.permission.CAMERA" />
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape" >
</activity>
我得到无法解析符号“ CaptureActivity”。我该怎么办?
我检查了其他stackoverflow帖子,但无法解决此问题。
您可以通过gradle依赖关系将zxing库添加到您的应用中
只需将此添加到您的build.gradle
文件
compile 'com.google.zxing:core:3.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.0.3@aar'
现在在您的活动的onCreate方法中,执行以下操作
IntentIntegrator scanIntegrator = new IntentIntegrator(MainActivity.this);
scanIntegrator.setPrompt("Scan a Barcode");
scanIntegrator.setBeepEnabled(true);
scanIntegrator.setOrientationLocked(true);
scanIntegrator.setBarcodeImageEnabled(true);
scanIntegrator.initiateScan();
您可以在此处找到示例项目
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句