allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
dependencies { implementation 'com.github.BayMax-Yi:BayMaxScanner:1.0.1' }
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_capture);
previewHelper = new PreviewHelper();
previewHelper.setScanType( PreviewHelper.SCANTYPE_QR);
previewHelper.setActivity(this);
previewHelper.setSurfaceHolder(surfaceView.getHolder());
previewHelper.setViewfinderView(viewfinderView);
//Set onDecodeListener for PreviewHelper and deal the decoded result in onDecodeListener.onDecodedResult(Result)
previewHelper.setOnDecodedResultListener(onDecodeListener);
//setScanType PreviewHelper.SCANTYPE_QR : Scan QrCode
// PreviewHelper.SCANTYPE_BARCIDE : Scan BarCode
previewHelper.onCreate();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
previewHelper.onCreate();
}
@Override
protected void onResume() {
super.onResume();
previewHelper.onResume();
}
@Override
protected void onPause() {
super.onPause();
previewHelper.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
previewHelper.onDestroy();
}