-1
バーコードをスキャンした後にzxingに何か問題があります。私が使用してzxingを呼び出す:IntentIntegratorで何をやっているのかわからない
IntentIntegrator.initiateScan(MainActivity.this);
をそして、私のonActivityResultがこの
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
if (format == "PRODUCT_CODE"){
//If the barcode scanned is of the correct type then pass the barcode into the search method to get the product details
Toast.makeText(getApplicationContext(),"You scanned " + contents, 3).show();
}
else{
//If the barcode is not of the correct type then display a notification
Toast.makeText(getApplicationContext(),"You didn't scan a product code", 3).show();
}
} else if (resultCode == RESULT_CANCELED) {
//If the scan is cancelled then display a notification
Toast.makeText(getApplicationContext(),"You cancelled the input", 3).show();
}
}
}
しかし、時はいつでも、私は何も表示されないzxing出るようになります。私は例in the zxing wiki を使用してみましたが、あなたの動作をMainActivityまたはMainActivityに置き換えようとすると、エラーが発生します。MainActivityは文字列に解決できずMainActivity.thisでコンストラクタIntentIntegrator(MainActivity)が定義されていません。
基本的に私は何をやっているのか、それがなぜ機能していないのか分かりません。どんな助けでも大歓迎です。