導航:首頁 > 操作系統 > androidgooglezxing

androidgooglezxing

發布時間:2022-10-03 07:07:47

❶ 在android中使用googlezxing實現二維碼

先打開本地下載,復制文件,拷貝到他們的項目中即可。
首先我們打開google的zxing的地址,googledezxing地址(本地下載),打開之後我們會看到界面,將這個文件下載我們本地,下載好之後我們需要復制android文件下的幾個類,根據這些類名稱在android文件下找到這些類,拷貝到他們的項目中,拷貝之後會有報錯,我們需要將android文件下的res中的文件也拷貝到我們的項目中。完成之後我們還要依賴zxing的核心類庫,當我們的項目不報錯的時候,就可以先實現掃描二維碼和生成二維碼。

❷ android studio怎麼導入對zxing的依賴

下面分兩種情況介紹一下如何導入第三方類庫。 1、對於jar的類庫,非常簡單,只要在項目根目錄下新建一個libs目錄,然後把jar復制進去,在jar上點擊右鍵,選擇Add as library,即可完成依賴的添加。 2、對於github等網站上下載的源碼類庫,是無法通過這種方式添加的。首先把git clone下來的整個文件夾放入項目根目錄下,這里以我自己的開發包為例,我的開發包名字是ShunixDevKit,裡面有一個lib目錄才是真正的類庫,那麼我們要做的就是手動在settings.gradle裡面添加: include ':ShunixDevKit:lib' 注意,gradle使用:作為路徑分隔符。這樣Android Studio就知道了我們的類庫放在哪裡,當然這樣還是不夠的,要讓項目能使用類庫,我們還需要添加這個類庫作為項目的依賴,選擇File->Project Structure,然後選中主mole的名稱,點擊dependencies,添加:ShunixDevKit:lib就可以了,gradle的build就能成功。 以上就是添加第三方類庫作為依賴的過程。這里需要注意一下的地方就是,導入的類庫根目錄下的gradlew文件一定要可執行,否則Android Studio會提示錯誤,而且根據錯誤信息很難找出來這個錯誤,我自己因為這個搞了很久,希望對大家有幫助。

❸ 如何用Zxing解析pdf417-Android開發問答

1.如何將zxing的Android源碼導入工程。
在導入zxing的android源碼之前,先去官方下載zxing的源碼:http://code.google.com/p/zxing/downloads/list。
我這里下載的是1.6版本的,我試驗了幾個版本,發現2.0以後的版本實際用起來沒有1.6和1.7版本的好用,最後選擇了1.6版本。

在導入之前先要對core文件下的源碼進行編譯,得到核心包core.jar。
編譯方法請參照:http://blog.163.com/yimigao@126/blog/static/671560502011611111116747/
然後就可以導入android平台下的例子了,導入方法如下:
1)打開Eclipse,新建android項目:(注意不要直接把android文件夾拷到workspace下導入,那樣會無法導入)

2)導入核心包core.jar。
3)修改strings.xml文件。在導入core.jar之後工程還是會有錯誤:

出現這種錯誤可能是由於字元錯誤導致的,只需要把所有的%s 和%f改成 %1s和f 即可。
修改完之後重新清理項目,此時已經沒有錯誤了:

2.代碼簡化
上面代碼中,很多功能我們在自己的項目中都用不到,因此需要對其進行簡化,至於如何簡化這里就不贅述了,網上有很多教程。下面只給出簡化後的結果:

如果只進行二維碼識別和二維碼生成的話,只需要上麵包中的文件。其中CaptureActivity.java是拍照取景的類,camera包下面的類主要與照相機相關的類,decoding和encoding是解碼和編碼相關的類,view是取景框相關的類。
3.將簡化的zxing代碼嵌入自己的工程。
在自己的工程中嵌入簡化的zxing代碼即可實現二維碼生成和識別功能。
嵌入方法:
1)將上述簡化的代碼拖到自己工程目錄下;
2)將values文件夾和raw文件夾復制自己工程目錄下;
3)建立CaptureActivity.java的布局文件capture.xml。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<SurfaceView
android:id="@+id/preview_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />

<com.zxing.view.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="Scan Barcode"
android:textColor="@android:color/white"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/btn_cancel_scan"
android:layout_width="230dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="75dp"
android:text="Cancel"
android:textSize="15sp"
android:textStyle="bold" />

</RelativeLayout>

</FrameLayout>

3)導入core.jar包
4)修改AndrodMainfest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.qrcode"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.VIBRATE" /> <!-- 震動許可權 -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" /> <!-- 使用照相機許可權 -->
<uses-feature android:name="android.hardware.camera.autofocus" /> <!-- 自動聚焦許可權 -->

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- 隱藏鍵盤 --><!-- 全屏 -->
<activity
android:configChanges="orientation|keyboardHidden"
android:name="com.zxing.activity.CaptureActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>

</application>
</manifest>

❹ 安卓調用zxing掃碼之後返回結果為空

建議你使用Android應用作為客戶端,去訪問網站里的應用,比如webapp的servlet。有兩種方式: 1)使用JSON RPC 調用 servlet的方法; 2)使用HttpClient對象訪問網站的URL。

❺ Android使用zxing報錯"ActivityNotFoundException"怎麼解決

你出現ActivityNotFoundException錯誤是因為Zxing應用沒有在你的設備上安裝.所以,請檢查是否安裝.如果沒有,可以將你的用戶重定向到Goolge Play的Zxing頁.下面這些代碼可以幫你:

boolean isZxingInstalled;
/*
*Checking whether Zxing is installed or not
*/
try
{
ApplicationInfo info = getPackageManager().getApplicationInfo("com.google.zxing.client.android", 0 );
boolean isZxingInstalled = true;
}
catch(PackageManager.NameNotFoundException e){
isZxingInstalled=false;
}

/*
* Store the boolean value on the basis of Zxing is installed or not
*/

if(isZxingInstalled) //If it is then intent Zxing application
{
//start the facebook app
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.setPackage("com.google.zxing.client.android");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
intent.putExtra("SCAN_FORMATS", "CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF,CODABAR,EAN_13,EAN_8,UPC_A,QR_CODE");
startActivityForResult(intent, 0);
}
else //It's not then redirect user to PlayStore-ZxingPlage
{
/*
*Checking whether PlayStore is installed in device or not?
*/
boolean isPlayStoreInstalled
try
{
ApplicationInfo i=getPackageManager().getApplicationInfo("com.google.vending", 0 );
boolean isPlayStoreInstalled = true;
}
catch(PackageManager.NameNotFoundException e){
isPlayStoreInstalled=false;
}

/*
* If it is the download Zxing
*/
if(isPlayStoreInstalled)
{
Intent DownloadZxing = new Intent(Intent.ACTION_VIEW,Uri.parse("market://detailsid=com.google.zxing.client.android"));
startActivity(DownloadZxing);
}
else //Toast message indicating No PlayStore Found
{
Toast.makeText(this,"Install PlayStore First",Toast.LENGHT_SHORT).show();
}
}

❻ 請教一下Android Studio中ZXING的用法

因為這個zxing的庫是屬於library,如果你復制到項目中以後,會有緩存問題
你可以先clean一下項目,將緩存文件清除
建議使用Android Studio做開發工具,Android studio是基於Intellij IDEA專門為安卓開發的IDE,自從android Studio 1.0正式版發布以後google已經正式使用android Studio了,目前版本是 1.3.2 正式版

❼ android zxing需要哪些許可權

在導入zxing的android源碼之前,先去官方下載zxing的源碼:http://code.google.com/p/zxing/downloads/list。
我這里下載的是1.6版本的,我試驗了幾個版本,發現2.0以後的版本實際用起來沒有1.6和1.7版本的好用,最後選擇了1.6版本。
zxing 1.6源碼結構如下:

❽ android版本jar包怎麼導入

在android上導入zxing.jar包,總是報錯:Could not find class 'com.google.zxing.MultiFormatWriter', referenced from method com.changyang.app.util.Encode2dUtil.creat2DCode後來找到了解決方法:在adt17 的版本之前,導入第三方jar包時要建立一個lib目錄,並 add to buiild path。在adt17的版本之後,導入第三方jar包,要建立一個libs目錄,不能使用lib命名,adt會自動將jar依賴。不用手動添加了。

❾ android studio 怎麼引用Zxing包

1.下載ZXing庫

首先需要一個ZXing庫和Core Jar包
ZXing庫: https://github.com/zxing/zxing
Core Jar包 :http://repo1.maven.org/maven2/com/google/zxing/core/3.2.1/core-3.2.1.jar
主要是用紅框那兩個包,而core包你可以編譯成jar包或者用我上面那個jar包鏈接下載。

2.接入

在你項目中,File -> New -> Import Mole 把剛下載的android包添加進入

其實現在是兩個項目,為了區別是依賴庫,首先在File -> Project Strcture -> 在Mole選擇自己的項目 Dependencies ->加上Mole Dependency ,然後在ZXing的build.gradle下第一行改成如下,還有把下面的 applicationId那行刪掉。
修改前
apply plugin: 'com.android.application'

修改後
apply plugin: 'com.android.library'
1
2
3
4
5
1
2
3
4
5

然後會報一堆紅色錯誤,這是正常的。下一步是把Core Jar包導入ZXing,在ZXing創建一個libs文件夾,把Core Jar放進去,然後右鍵 As Add Library。

錯誤已經沒了一半,接下來發現會少一個CameraConfigurationUtils類,這個就是剛才在android-core下的那一個類,把它拖到camera包下就好了。

接下來的錯誤都能Alt+Enter解決,把Switch改成if else。到這步不行的同學可以試試移除Mole再試試。

運行時就會報Execution failed for task 『app:processDebugManifest』,只要自己項目的AndroidManifest.xml文件 application標簽加上 tools:replace=」icon,theme」,然後alt+Enter導入命名空間就好了。
3.使用

在自己的項目中startActivity CaptureActivity 就可以了。

返回的數據在這行代碼裡面。
CharSequence displayContents = resultHandler.getDisplayContents();
1
1

至於橫屏改為豎屏,在AndroidManifest.xml文件的CaptureActivity 改一下就好了。
android:screenOrientation="portrait"

❿ android zxing 二維碼 怎麼用

http://repo1.maven.org/maven2/com/google/zxing/android-core/3.2.1/android-core-3.2.1.jar

導入這個jar包,使用方法見GitHub

https://github.com/zxing/zxing
閱讀全文

與androidgooglezxing相關的資料

熱點內容
matlab歷史命令 瀏覽:218
主角穿越到工作細胞的小說 瀏覽:102
九十年代香港老太太鬼電影 瀏覽:871
特工劉堅是李連傑的哪部電影 瀏覽:334
極坐標運演算法則 瀏覽:605
十大香港全漏電影 瀏覽:335
小虎還鄉裡面的驢叫什麼 瀏覽:499
誰有小電影網址啊 瀏覽:376
香港滿清十大酷刑一共有幾部電影 瀏覽:709
icloud發件伺服器埠是什麼 瀏覽:572
天殘腳電影 瀏覽:335
十部必看剿匪電影 瀏覽:692
免費台灣理論 瀏覽:132
大地影院明天有什麼電影 瀏覽:483
金石學pdf 瀏覽:696
河南天工集團廣訊通伺服器地址 瀏覽:420
cad制圖常用命令 瀏覽:857
主角叫楚風重生都市的小說 瀏覽:212
單片機jnb指令 瀏覽:1002
可以觀看vip電視劇的網站 瀏覽:244