使用zxing-android-embedded的DecoratedBarcodeView时应用程序崩溃

时间:2019-07-01 08:51:38

标签: android zxing

我正在使用zxing-android-embedded库创建条形码扫描器视图。但是当我使用CaptureManager时,应用程序崩溃了。看看完整的代码:

公共类DecoderActivity扩展Activity实现DecoratedBarcodeView.TorchListener {

private CaptureManager manager;
private DecoratedBarcodeView scannerView;
private ViewfinderView viewFinder;
private ImageView flash, img;

@Override
public void onTorchOn()
{
    // TODO: Implement this method
}

@Override
public void onTorchOff()
{
    // TODO: Implement this method
}

@Override
protected void onCreate(Bundle savedInstanceState)
{
    // TODO: Implement this method
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_decoder);
    initialize(savedInstanceState);
    initializeLogic();
}

private void initialize(Bundle state)
{
    // TODO: Implement this method
    manager = new CaptureManager(this, scannerView);
    manager.initializeFromIntent(getIntent(), state);
    scannerView = findViewById(R.id.zxing_barcode_scanner);
    scannerView.setTorchListener(this);
    viewFinder = findViewById(R.id.zxing_viewfinder_view);
    if(!Utils.hasFlash(getApplicationContext())){
    }
}

private void initializeLogic()
{
    // TODO: Implement this method
    manager.decode();
}

@Override
protected void onPause()
{
    // TODO: Implement this method
    super.onPause();
    manager.onPause();
}

@Override
protected void onResume()
{
// TODO: Implement this method
    super.onResume();
    manager.onResume();
}

@Override
protected void onDestroy()
{
    // TODO: Implement this method
    super.onDestroy();
    manager.onDestroy();
}

@Override
protected void onStart()
{
    // TODO: Implement this method
    super.onStart();
}

@Override
protected void onSaveInstanceState(Bundle outState)
{
    // TODO: Implement this method
    super.onSaveInstanceState(outState);
    manager.onSaveInstanceState(outState);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    // TODO: Implement this method
    return scannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
}

}

我需要实现其他功能吗? 请帮忙。

0 个答案:

没有答案