如何在库中以编程方式打开 Flash(条码 Reader - Google 移动视觉)

How to Turn On Flash Programmatically in Library ( Barcode Reader - Google Mobile Vision )

条码Reader-Google移动视觉

https://github.com/ravi8x/Barcode-Reader

    <fragment
    android:id="@+id/barcode_scanner"
    android:name="info.androidhive.barcode.BarcodeReader"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:auto_focus="true"
    app:use_flash="false"
     />

有一个 app:use_flash 功能,但仅在 XML 中我无法在 java 文件中访问它,并且没有关于在示例应用程序中获取它的代码.

另外,我想知道这个库中是否包含从库中加载二维码图像并扫描其特征。

图书馆没有公开它。所以你有两个选择:

  1. 将库作为库模块添加到您的应用程序中,然后更改 class 以执行任何您想要的操作(包括添加一个参数来切换闪光灯)。
  2. 创建一个 class 扩展该片段,覆盖 onInflate 并将那里的 isFlash 更改为您想要的任何内容。它是私有的,所以你必须使用反射。