//IntentIntegrator intentIntegrator = new IntentIntegrator(getActivity()); IntentIntegrator intentIntegrator = IntentIntegrator.forSupportFragment(this); intentIntegrator .setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES) .setOrientationLocked(false)//扫描方向固定 .setCaptureActivity(AddOxygenScanActivity.class) // 设置自定义的activity .initiateScan(); // 初始化扫描
在Activity中创建IntentIntegrator对象 new IntentIntegrator(this),参数是Activity。
在Fragment中创建IntentIntegrator对象,IntentIntegrator.forSupportFragment(this),参数是Fragment。