在上一篇文章中,直接使用zxing的源码。 java
这一篇,将使用别人已经打包好的aar包。 android
aar下载:https://github.com/journeyapps/zxing-android-embedded git
把这些代码添加到项目的 build.gradle 文件里面,在从新编译一次,as会自动下载并加压aar,而后添加到外部库里面。 github
repositories { jcenter() } dependencies { compile 'com.journeyapps:zxing-android-embedded:3.0.1@aar' compile 'com.google.zxing:core:3.2.0' }
再而后直接输入这行代码,开始扫码 app
new IntentIntegrator(this).initiateScan(); // `this` is the current Activity
做者的项目中有几个例子,能够去看一下。 gradle
Samples: ui