开发者

how to develop the "Zxing" Barcode scanner application of PhoneGap android

开发者 https://www.devze.com 2023-03-26 07:48 出处:网络
I have an android appl开发者_如何学编程ication which reads the barcode for this, I used the \"Zxing\" library

I have an android appl开发者_如何学编程ication which reads the barcode for this, I used the "Zxing" library its working fine. But, I have another application which is developed in PhoneGap for android.

Now I want to use that Barcode application in this PhoneGap application

If any knows about this let me know

Thanks in advance


https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner.

use this coding this is working good


Zxing provides public intents for this. There are some details here but it basically involves:

public Button.OnClickListener mScan = new Button.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.setPackage("com.google.zxing.client.android");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        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");
            // Handle successful scan
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
}

You'll also want to check to see if the Barcode Scanner app is available, and either disable functionality or prompt the user to install it.

Edit: Obviously, I was being stupid and only half-read. You can integrate using this pre-made plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消