Java Zxing条形码扫描仪与android应用程序集成时不扫描条形码

Java Zxing条形码扫描仪与android应用程序集成时不扫描条形码,java,android,zxing,Java,Android,Zxing,嗨,我已经成功地将Zxing扫描仪集成到我的应用程序中,但我遇到的问题是,它不想扫描条形码,但它可以完美地扫描二维码。当我自己打开Zxing应用程序时,条形码扫描仪工作。只有当我从正在构建的应用程序中启动它时,它才起作用。以前有没有人遇到过这个问题并找到了解决方案 static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN"; //product barcode mode p

嗨,我已经成功地将Zxing扫描仪集成到我的应用程序中,但我遇到的问题是,它不想扫描条形码,但它可以完美地扫描二维码。当我自己打开Zxing应用程序时,条形码扫描仪工作。只有当我从正在构建的应用程序中启动它时,它才起作用。以前有没有人遇到过这个问题并找到了解决方案

 static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";


        //product barcode mode
        public void scanBar(View v) {
            try {

                Intent intent = new Intent(ACTION_SCAN);
                intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
                startActivityForResult(intent, 0);
            } catch (ActivityNotFoundException anfe) {
                //on catch, show the download dialog
                showDialog(BarcodeScanner.this, "No Scanner Found",  "Download a  scanner code activity?", "Yes", "No").show();
            }
        }

        // start qr stuff  //product qr code mode
        public void scanQR(View v) {
            try {
                //start the scanning activity from the   com.google.zxing.client.android.SCAN intent
                Intent intent = new Intent(ACTION_SCAN);
                intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
                startActivityForResult(intent, 0);
            } catch (ActivityNotFoundException anfe) {
                //on catch, show the download dialog
                showDialog(BarcodeScanner.this, "No Scanner Found", "Download a scanner code activity?", "Yes", "No").show();
            }
        }

        //alert dialog for downloadDialog
        private static AlertDialog showDialog(final Activity act,  CharSequence title, CharSequence message, CharSequence buttonYes,  CharSequence buttonNo) {
            AlertDialog.Builder downloadDialog = new  AlertDialog.Builder(act);
            downloadDialog.setTitle(title);
            downloadDialog.setMessage(message);
            downloadDialog.setPositiveButton(buttonYes, new   DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                    Uri uri = Uri.parse("market://search?q=pname:" +  "com.google.zxing.client.android");
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    try {
                        act.startActivity(intent);
                    } catch (ActivityNotFoundException anfe) {

                    }
                }
            });
             downloadDialog.setNegativeButton(buttonNo, new    DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            return downloadDialog.show();
           }
            //on ActivityResult method
           public void onActivityResult(int requestCode, int resultCode, Intent intent) {
              if (requestCode == 0) {
                if (resultCode == RESULT_OK) {
                   //get the extras that are returned from the intent
                    String tagNo = intent.getStringExtra("SCAN_RESULT");
                    String format =    intent.getStringExtra("SCAN_RESULT_FORMAT");
                    MySOAPCallActivity cs = new MySOAPCallActivity();

                    //tagNo = editTagNumber.getText().toString();

                    final GlobalClass globalVariable = (GlobalClass)     getApplicationContext();

                    // Get name and email from global/application context
                    String eventName  = globalVariable.getEventName();
                    if(Local.isSet(getApplicationContext(), "EventName"))
                    {
                        eventName = Local.Get(getApplicationContext(), "EventName");

                    }
                    if(eventName.length() > 0) {

                       TagParams params = new TagParams(cs, tagNo, eventName);

                        //Make yes no buttons visible
                        Button buttonYes =     (Button)findViewById(R.id.buttonYes);
                        Button buttonNo = (Button)findViewById(R.id.buttonNo);
                       buttonYes.setVisibility(View.VISIBLE);
                       buttonNo.setVisibility(View.VISIBLE);

                        TextView nameSurname = (TextView)    findViewById(R.id.nameSurname);
                        nameSurname.setText("");
                        TextView idNumber = (TextView) findViewById(R.id.idNumber);
                        idNumber.setText("");
                        TextView ticketClass = (TextView)    findViewById(R.id.ticketClass);
                        ticketClass.setText("");



                        new CallSoapTicketValidForEvent().execute(params);
                    }

                }

                ;
            }
        }
这是渐变

apply plugin: 'com.android.application'

android {
        signingConfigs {
        }
        compileSdkVersion 23
        buildToolsVersion '23.0.1'
        defaultConfig {
            applicationId "com.dsouchon.TicketingMiiD"
            minSdkVersion 16
            targetSdkVersion 21
           versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
            }
        }
        productFlavors {
        }
    }
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-   dependencies.jar')
        compile 'com.android.support:appcompat-v7:23.0.1'
        compile 'com.google.android.gms:play-services:7.0.0'
       compile files('libs/CircleImageView-master/gradle/wrapper/gradle-    wrapper.jar')
       compile 'de.hdodenhof:circleimageview:2.0.0'
       compile 'com.jakewharton:process-phoenix:1.1.1'
     }

尝试以下可能对你有用

请在打开扫描代码时指定代码格式,如下所示:

intent.putExtra("SCAN_FORMATS", "CODABAR");
以下是格式列表:

/** QR Code 2D barcode format. */
public static final BarcodeFormat QR_CODE = new BarcodeFormat("QR_CODE");

/** DataMatrix 2D barcode format. */
public static final BarcodeFormat DATA_MATRIX = new BarcodeFormat("DATA_MATRIX");

/** UPC-E 1D format. */
public static final BarcodeFormat UPC_E = new BarcodeFormat("UPC_E");

/** UPC-A 1D format. */
public static final BarcodeFormat UPC_A = new BarcodeFormat("UPC_A");

/** EAN-8 1D format. */
public static final BarcodeFormat EAN_8 = new BarcodeFormat("EAN_8");

/** EAN-13 1D format. */
public static final BarcodeFormat EAN_13 = new BarcodeFormat("EAN_13");

/** UPC/EAN extension format. Not a stand-alone format. */
public static final BarcodeFormat UPC_EAN_EXTENSION = new BarcodeFormat("UPC_EAN_EXTENSION");

/** Code 128 1D format. */
public static final BarcodeFormat CODE_128 = new BarcodeFormat("CODE_128");

/** Code 39 1D format. */
public static final BarcodeFormat CODE_39 = new BarcodeFormat("CODE_39");

/** Code 93 1D format. */
public static final BarcodeFormat CODE_93 = new BarcodeFormat("CODE_93");

/** CODABAR 1D format. */
public static final BarcodeFormat CODABAR = new BarcodeFormat("CODABAR");

/** ITF (Interleaved Two of Five) 1D format. */
public static final BarcodeFormat ITF = new BarcodeFormat("ITF");

/** RSS 14 */
public static final BarcodeFormat RSS14 = new BarcodeFormat("RSS14");

/** PDF417 format. */
public static final BarcodeFormat PDF417 = new BarcodeFormat("PDF417");

/** RSS EXPANDED */
public static final BarcodeFormat RSS_EXPANDED = new BarcodeFormat("RSS_EXPANDED");

尝试以下可能对你有用

请在打开扫描代码时指定代码格式,如下所示:

intent.putExtra("SCAN_FORMATS", "CODABAR");
以下是格式列表:

/** QR Code 2D barcode format. */
public static final BarcodeFormat QR_CODE = new BarcodeFormat("QR_CODE");

/** DataMatrix 2D barcode format. */
public static final BarcodeFormat DATA_MATRIX = new BarcodeFormat("DATA_MATRIX");

/** UPC-E 1D format. */
public static final BarcodeFormat UPC_E = new BarcodeFormat("UPC_E");

/** UPC-A 1D format. */
public static final BarcodeFormat UPC_A = new BarcodeFormat("UPC_A");

/** EAN-8 1D format. */
public static final BarcodeFormat EAN_8 = new BarcodeFormat("EAN_8");

/** EAN-13 1D format. */
public static final BarcodeFormat EAN_13 = new BarcodeFormat("EAN_13");

/** UPC/EAN extension format. Not a stand-alone format. */
public static final BarcodeFormat UPC_EAN_EXTENSION = new BarcodeFormat("UPC_EAN_EXTENSION");

/** Code 128 1D format. */
public static final BarcodeFormat CODE_128 = new BarcodeFormat("CODE_128");

/** Code 39 1D format. */
public static final BarcodeFormat CODE_39 = new BarcodeFormat("CODE_39");

/** Code 93 1D format. */
public static final BarcodeFormat CODE_93 = new BarcodeFormat("CODE_93");

/** CODABAR 1D format. */
public static final BarcodeFormat CODABAR = new BarcodeFormat("CODABAR");

/** ITF (Interleaved Two of Five) 1D format. */
public static final BarcodeFormat ITF = new BarcodeFormat("ITF");

/** RSS 14 */
public static final BarcodeFormat RSS14 = new BarcodeFormat("RSS14");

/** PDF417 format. */
public static final BarcodeFormat PDF417 = new BarcodeFormat("PDF417");

/** RSS EXPANDED */
public static final BarcodeFormat RSS_EXPANDED = new BarcodeFormat("RSS_EXPANDED");

调试代码你发现了什么吗?共享你的代码和build.gradle?@abhijitchara我在调试中没有发现任何东西。@MithunSarkerShuvro iv将代码附在上面调试扫描仪活动?调试代码你发现了什么吗?共享你的代码和build.gradle?@abhijitchara我在调试中没有发现任何东西。@MithunSarkerShuvro iv将代码附在“调试扫描仪活动”储罐上。最后一个很有效。我不得不把它改成“39码”坦克。最后一个很有效。我不得不把它改成“代码39”