android項目中使用zxing掃碼(二)

在上一篇文章中,直接使用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

注:在個人手機上運行掃碼,直接出現一個全屏的掃碼界面,掃碼的範圍很大很大,建議根據本身的需求去定製。
相關文章
相關標籤/搜索