引用zxing jar包为什么找不到captureactivity

2025-04-08 21:49:03
推荐回答(1个)
回答1:

你出现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_三9,CODE_9三,CODE_依贰吧,DATA_MATRIX,ITF,CODABAR,EAN_依三,EAN_吧,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(); }