Android, How to read QR code in my application?

前端 未结 7 1992
耶瑟儿~
耶瑟儿~ 2020-11-29 16:11

In my application I need to read Qr code. I searched the net and found Zing codes however lots of developers had problem with using it and it seems it is buggy!

If i

7条回答
  •  不知归路
    2020-11-29 16:38

    I've created a simple example tutorial. You can read this and use in your application.

    http://ribinsandroidhelper.blogspot.in/2013/03/qr-code-reading-on-your-application.html

    Through this link you can download the qrcode library project and import into your workspace and add library to your project

    and copy this code to your activity

     Intent intent = new Intent("com.google.zxing.client.android.SCAN");
     startActivityForResult(intent, 0);
    
     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");
                 Toast.makeText(this, contents,Toast.LENGTH_LONG).show();
                 // Handle successful scan
             } else if (resultCode == RESULT_CANCELED) {
                 //Handle cancel
             }
         }
    }
    

提交回复
热议问题