【发布时间】:2016-07-20 11:14:23
【问题描述】:
我正在使用模块“react-native-barcodescanner”来读取条形码,但安卓手机只能扫描二维码。如何在 ract-native 应用程序中读取各种条形码。
【问题讨论】:
标签: android npm react-native
我正在使用模块“react-native-barcodescanner”来读取条形码,但安卓手机只能扫描二维码。如何在 ract-native 应用程序中读取各种条形码。
【问题讨论】:
标签: android npm react-native
你必须在构建语句中一一设置Bacode Format,
以下是支持的格式
BarcodeFormat.UPC_A
BarcodeFormat.UPC_E
BarcodeFormat.EAN_13
BarcodeFormat.EAN_8
BarcodeFormat.RSS_14
BarcodeFormat.CODE_39
BarcodeFormat.CODE_93
BarcodeFormat.CODE_128
BarcodeFormat.ITF
BarcodeFormat.CODABAR
BarcodeFormat.QR_CODE
BarcodeFormat.DATA_MATRIX
BarcodeFormat.PDF_417
像下面的例子
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.setFormats(BarcodeFormat.UPC_A)
.setFormats(BarcodeFormat.EAN_13)
.setFormats(BarcodeFormat.CODE_93)
.setFormats(BarcodeFormat.CODE_128)
.addPackage(new MainReactPackage())
.addPackage(new RNCameraViewPackage()) // <------ add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
【讨论】:
图书馆工作正常,我们只需要在横向模式下扫描条形码。
【讨论】: