欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android sdutio配置Zxing進(jìn)行掃碼功能的實(shí)現(xiàn)方法

 更新時(shí)間:2017年05月12日 11:46:59   投稿:mrr  
這篇文章主要介紹了Android sdutio配置Zxing進(jìn)行掃碼功能的實(shí)現(xiàn)方法,需要的朋友可以參考下

github開源項(xiàng)目(Zxing)demo

最快的調(diào)用Zxing方法

1.關(guān)聯(lián)第三方庫(kù)

2.調(diào)用基礎(chǔ)的掃碼

3.獲取返回值

具體代碼如下:

//1.默認(rèn)選項(xiàng)啟動(dòng)意圖
new IntentIntegrator(MainActivity.this).initiateScan(); // `this` is the current Activity
//2.獲取得到的結(jié)果:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
 if(result != null) {
  if(result.getContents() == null) {
   Toast.makeText(this, "取消掃碼", Toast.LENGTH_LONG).show();
  } else {
   Toast.makeText(this, "掃碼結(jié)果:" + result.getContents(), Toast.LENGTH_LONG).show();
  }
 } else {
  super.onActivityResult(requestCode, resultCode, data);
 }
}

MainActivity.java

apply plugin: 'com.android.application'
android {
 compileSdkVersion 25
 buildToolsVersion "25.0.2"
 defaultConfig {
  applicationId "wei.shm.zxingscancode"
  minSdkVersion 15
  targetSdkVersion 25
  versionCode 1
  versionName "1.0"
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 }
 buildTypes {
  release {
   minifyEnabled false
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
 }
}
dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
  exclude group: 'com.android.support', module: 'support-annotations'
 })
 compile 'com.android.support:appcompat-v7:25.2.0'
 compile 'com.android.support.constraint:constraint-layout:1.0.1'
 testCompile 'junit:junit:4.12'
 //新建項(xiàng)目只增加這個(gè)
 compile 'com.journeyapps:zxing-android-embedded:3.5.0'
 //需要核對(duì)的有:
 //1.備置倉(cāng)庫(kù):repositories里的jcenter()
 //2.com.android.support:appcompat-v7:版本號(hào)必須大于23以上
 //3.buildToolsVersion:版本需要大于等于23.0.2,舊版本可能會(huì)導(dǎo)致編譯錯(cuò)誤
 //以上條件都滿足則只需要添加 compile 'com.journeyapps:zxing-android-embedded:3.5.0'
}

IntentIntegrator相關(guān)方法注解翻譯

setCaptureActivity:設(shè)置活動(dòng)類使用。它可以是任何活動(dòng),但應(yīng)處理的意圖額外使用這里。

setPrompt:設(shè)置一個(gè)提示顯示在捕捉屏幕上,而不是使用默認(rèn)。

setOrientationLocked:默認(rèn)情況下,方向鎖定。設(shè)置為false不鎖定。

setCameraId:使用指定的相機(jī)ID。

setBeepEnabled:設(shè)置為false禁用掃描的嗶嗶聲。

setBarcodeImageEnabled:設(shè)置為true,以便在結(jié)果意圖中保存條形碼圖像并發(fā)送其路徑。

setDesiredBarcodeFormats:設(shè)置所需的條碼格式掃描。

initiateScan:啟動(dòng)掃描所有已知的條形碼類型與默認(rèn)相機(jī)。

setTimeout:啟動(dòng)掃描所有已知的條形碼類型與默認(rèn)相機(jī)。并啟動(dòng)計(jì)時(shí)器超時(shí)完成

createScanIntent:使用指定選項(xiàng)創(chuàng)建掃描意圖。

以上所述是小編給大家介紹的Android sdutio配置Zxing進(jìn)行掃碼功能的實(shí)現(xiàn)方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論