getting scan result when using zxing?

前端 未结 5 353
心在旅途
心在旅途 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:56

    In your onActivityResult do like following code

        IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if(result != null) {
            if(result.getContents() == null) {
                Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
            } else {
               String qrCode=result.getContents();
            }
        } else {
            // This is important, otherwise the result will not be passed to the fragment
            super.onActivityResult(requestCode, resultCode, data);
        }
    

    You haven't called result.getContents().

提交回复
热议问题