How to decode QR code

前端 未结 5 1643
[愿得一人]
[愿得一人] 2020-12-14 05:31

I like decode QR Code directly in my application, I don\'t wont to redirect my application to other intent. I try very hard to find any API or Library, from which I can deco

5条回答
  •  孤街浪徒
    2020-12-14 05:33

    static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";
    
    
    // Bar Code
    
    public void scanBarCode(View v) {
    
            try {
                //start the scanning activity from the com.google.zxing.client.android.SCAN intent
    
                Intent intent = new Intent(ACTION_SCAN);
    
                intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
    
                startActivityForResult(intent, 0);
    
            } catch (ActivityNotFoundException anfe) {
    
                //on catch, show the download dialog
    
                showDialog(AndroidBarcodeQrExample.this, "No Scanner Found", "Download a scanner code activity?", "Yes", "No").show();
            }
        }
    
    
    // QR Code
    
        public void scanQR(View v) {
    
            try {
    
                //start the scanning activity from the com.google.zxing.client.android.SCAN intent
    
                Intent intent = new Intent(ACTION_SCAN);
    
                intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
    
                startActivityForResult(intent, 0);
    
            } catch (ActivityNotFoundException anfe) {
    
                //on catch, show the download dialog
    
                showDialog(AndroidBarcodeQrExample.this, "No Scanner Found", "Download a scanner code activity?", "Yes", "No").show();
            }
        }
    

提交回复
热议问题