Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用android嵌入式zxing(Java)时出现黑屏_Java_Android_Camera_Qr Code_Zxing - Fatal编程技术网

使用android嵌入式zxing(Java)时出现黑屏

使用android嵌入式zxing(Java)时出现黑屏,java,android,camera,qr-code,zxing,Java,Android,Camera,Qr Code,Zxing,我正试图遵循GitHub中zxing页面中显示的连续QRCode扫描仪示例。问题是,当我在我的设备上运行项目时,我得到的只是一个黑屏,而不是手机摄像头的预览。下面是我在SelecionarDuinoActivity.java中的代码: public class SelecionarArduinoActivity extends AppCompatActivity { private SelecionarArduinoController controller; private

我正试图遵循GitHub中zxing页面中显示的连续QRCode扫描仪示例。问题是,当我在我的设备上运行项目时,我得到的只是一个黑屏,而不是手机摄像头的预览。下面是我在SelecionarDuinoActivity.java中的代码:

public class SelecionarArduinoActivity extends AppCompatActivity {

    private SelecionarArduinoController controller;
    private DecoratedBarcodeView barcodeView;
    private BeepManager beepManager;
    private String lastText;

    private BarcodeCallback callback = new BarcodeCallback() {
        @Override
        public void barcodeResult(BarcodeResult result) {
            if(result.getText() == null || result.getText().equals(lastText)){
                return;
            }

            lastText = result.getText();
            barcodeView.setStatusText(result.getText());
            beepManager.playBeepSoundAndVibrate();
            ImageView imageView = findViewById(R.id.barcodePreview);
            imageView.setImageBitmap(result.getBitmapWithResultPoints(Color.YELLOW));
        }

        @Override
        public void possibleResultPoints(List<ResultPoint> resultPoints) {
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_selecionar_arduino);
        barcodeView = findViewById(R.id.barcode_scanner);
        Collection<BarcodeFormat> formats = Arrays.asList(BarcodeFormat.QR_CODE);
        barcodeView.getBarcodeView().setDecoderFactory(new DefaultDecoderFactory(formats));
        barcodeView.initializeFromIntent(getIntent());
        barcodeView.decodeContinuous(callback);

        beepManager = new BeepManager(this);
        controller = new SelecionarArduinoController(SelecionarArduinoActivity.this);
    }

公共类SelecionArrDuinoActivity扩展了AppCompatActivity{
专用SELECIONARDUINO控制器;
私人装饰条码视图条码视图;
私人经理;
私有字符串文本;
私有BarcodeCallback回调=新的BarcodeCallback(){
@凌驾
公共无效条形码结果(条形码结果){
if(result.getText()==null | | result.getText().equals(lastText)){
返回;
}
lastText=result.getText();
barcodeView.setStatusText(result.getText());
beepManager.playbeepsoundvibrate();
ImageView ImageView=findViewById(R.id.barcodePreview);
setImageBitmap(result.getBitmapWithResultPoints(Color.YELLOW));
}
@凌驾
公共无效可能结果点(列出结果点){
}
};
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u selecionar\u arduino);
条形码视图=findViewById(R.id.barcode\U扫描器);
收集格式=数组.asList(条形码格式.QR\u代码);
getBarcodeView().setDecoderFactory(新的DefaultDecoderFactory(格式));
InitializeFrominent(getIntent());
barcodeView.decodeContinuous(回调);
beepManager=新的beepManager(此);
控制器=新的SelecionArrDuinoController(SelecionArrDuinoActivity.this);
}
对于我的xml布局,我得到了:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.journeyapps.barcodescanner.DecoratedBarcodeView
        android:id="@+id/barcode_scanner"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_above="@+id/buttonsLayout"
        android:layout_alignParentTop="true">

    </com.journeyapps.barcodescanner.DecoratedBarcodeView>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:id="@+id/buttonsLayout"
        android:layout_toLeftOf="@+id/centerHorizont">

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Pause"
            />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Resume"
            />
    </LinearLayout>

    <View
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:id="@+id/centerHorizont" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/centerHorizont"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@id/buttonsLayout"
        android:id="@+id/barcodePreview" />

</RelativeLayout>


在这一点上,请忽略暂停和恢复按钮,我得到了它的例子,但我不打算使用它

最后,我的Logcat结果:

03/11 18:42:19: Launching 'app' on Xiaomi Mi A3.
$ adb shell am start -n "br.usp.ardhouse/br.usp.ardhouse.activity.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 13138 on device 'xiaomi-mi_a3-d0c96fd050b8'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/Perf: Connecting to perf service.
E/Perf: Fail to get file list br.usp.ardhouse
    getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
E/Perf: Fail to get file list br.usp.ardhouse
    getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
W/br.usp.ardhous: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/br.usp.ardhous: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
I/AdrenoGLES: QUALCOMM build                   : 1604d02, I97efb879e3
    Build Date                       : 09/25/19
    OpenGL ES Shader Compiler Version: EV031.27.05.02
    Local Branch                     : 
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
    Build Config                     : S P 8.0.11 AArch64
I/AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
W/AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
W/AdrenoUtils: <ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
W/RenderThread: type=1400 audit(0.0:342325): avc: denied { search } for name="kgsl" dev="sysfs" ino=36975 scontext=u:r:untrusted_app:s0:c216,c256,c512,c768 tcontext=u:object_r:sysfs_kgsl:s0 tclass=dir permissive=0
W/Gralloc3: mapper 3.x is not supported
W/System: A resource failed to call close. 
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@433ea66

03/11 18:42:19:在小米A3上发布“应用程序”。
$adb shell am start-n“br.usp.ardhouse/br.usp.ardhouse.activity.MainActivity”-a android.intent.action.MAIN-c android.intent.category.LAUNCHER
连接至装置“小米-mi_a3-d0c96fd050b8”上的过程13138。
从应用程序捕获和显示logcat消息。可以在“调试器”设置页面的“logcat输出”部分禁用此行为。
I/Perf:连接到性能服务。
E/Perf:无法获取文件列表br.usp.ardhouse
getFolderSize():Exception_1=java.lang.NullPointerException:尝试获取null数组的长度
E/Perf:无法获取文件列表br.usp.ardhouse
getFolderSize():Exception_1=java.lang.NullPointerException:尝试获取null数组的长度
W/br.usp.ardhous:访问隐藏方法Landroid/view/view;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z(灰色列表,允许反射)
W/br.usp.ardhous:访问隐藏方法Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V(灰色列表,允许反射)
I/AdrenoGLES:高通公司制造:1604d02,I97efb879e3
建造日期:19年9月25日
OpenGL ES着色器编译器版本:EV031.27.05.02
本地分行:
远程分支:
远程分支:
重建分支机构:
构建配置:SP 8.0.11 AArch64
I/AdrenoGLES:PFP:0x016ee187,ME:0x00000000
W/AdrenoUtils::无法打开/sys/class/kgsl/kgsl-3d0/gpu模型
W/AdrenoUtils::无法从gpu_型号读取芯片ID。请回退以使用GSL路径
W/RenderThread:type=1400审核(0.0:342325):avc:denied{search}for name=“kgsl”dev=“sysfs”ino=36975 scontext=u:r:untrusted\u app:s0:c216、c256、c512、c768 tcontext=u:object\r:sysfs\u kgsl:s0 tclass=dir permissive=0
W/Gralloc3:不支持映射程序3.x
W/系统:资源调用close失败。
W/ActivityThread:handleWindowVisibility:标记android.os没有活动。BinderProxy@433ea66