2017-02-08 19 views
0

こんにちは、私のアプリにZxingスキャナーを統合しましたが、問題はバーコードをスキャンしたくないですが、 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); 
        } 

       } 

       ; 
      } 
     } 

そして、ここでのGradle

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' 
    } 
+0

デバッグあなたは何を見つけたのですか? –

+0

あなたのコードとbuild.gradleを共有しますか? –

+0

@AbhijitChakra私はデバッグで何かを見つけました。 –

答えて

0

には、次の試しているそれはあなたのために働くかもしれません。

あなたが道を次のようにスキャンコードのためのオープン意図されているとき、コードギを指定してください:

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"); 
+0

タンク。この最後の1つはうまくいった。私はそれを "CODE_39"に変更しなければならなかった –

関連する問題