Getting started with ZXing on Android

后端 未结 8 819
野性不改
野性不改 2021-01-06 12:05

I\'m trying to add ZXing to my project (add a button which calls the scanner upon press). I found this: http://groups.google.com/group/android-developers/browse_thread/threa

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-06 12:26

    Go here for links.

    In the activity that you want to trigger a barcode scan include

    IntentIntegrator.initiateScan(YourActivity.this); 
    

    and then also include:

    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
                TextView 
            } else if (resultCode == RESULT_CANCELED) {
                // Handle cancel
            }
        }
    };
    

    The Barcode Scanner app will handle the actual scanning. If the Barcode Scanner app is not installed, the integrator will prompt them to install it.

    ----------- From nEx.Software ---------------

提交回复
热议问题