1

友達私はバーコードスキャナーを開発しようとしています。作業フローは次のとおりです。ユーザーがスキャンボタンをクリックすると、バーコードの画像をキャプチャし、この画像をスキャンして結果を表示する必要があります。問題は、スキャンボタンをクリックすると、「バーコードスキャナーをインストールしてください」というメッセージが表示されることです。このアプローチを使用します。私のコードで何を変更するのですか????、これが私のコードです。

    IntentIntegrator integrator = new IntentIntegrator(BarcodeScanner.this);
    integrator.initiateScan();

    scan_btn = (Button)findViewById(R.id.Barcode_Scan_Button);
    scan_btn.setOnClickListener( new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent scanIntent= new Intent("com.google.zxing.client.android.SCAN");
            scanIntent.putExtra("SCAN_MODE", "QR_CODE_MODE");

            startActivityForResult(scanIntent, 0);

        }
    });
}

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
      if (scanResult != null) {
          result_text.setText(intent.getStringExtra("SCAN_RESULT"));
      }
      else
          result_text.setText("Scan cancelled.");

    }

}
4

1 に答える 1

3

There is nothing to change, you are calling an external BarcodeScanner application, namely the ZXing app. If it isn't present on your device, it will prompt you to install it.

If you don't like this behaviour, then you can either try writing your BarcodeScanner logic, or integrate the ZXing code in your application since it's open source, however I advice you not to do that, becuase that is not the purpose of the ZXing project.

于 2012-07-04T07:41:15.030 に答える