getting scan result when using zxing?

前端 未结 5 401
心在旅途
心在旅途 2021-01-03 11:51

I am currently using the Zxing library in my app. After scanning the bar code of a book for example, how do I get things like the image, description, etc. from the scan resu

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 12:51

    You dont need the 'IntentResult' or 'IntentIntegrator' for that.
    You can do this:

    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
    startActivityForResult(intent, 0);
    

    And then in onActivityResult:

    if (requestCode == 0) {
        if ((resultCode == RESULT_CANCELED) || (resultCode == -1000)) {
        Toast.makeText(WebViewActivity.this, "Nothing captured",
                        Toast.LENGTH_SHORT).show();
    } else {
        String capturedQrValue = data.getStringExtra("barcode_data");
    }
    }
    

    With this you scan the barcode, now there is in the Zxing code another library that uses Google API for looking up that ISBN. In the class Intents.java you have the info of what extras the intent needs and the class ISBNResultHandler shows what is the result. Hope it helps someone in the future.

提交回复
热议问题