Android 找到二维码后如何在中兴重启摄像头
当Zxing找到二维码时,它会将其传送到Android 找到二维码后如何在中兴重启摄像头,android,zxing,Android,Zxing,当Zxing找到二维码时,它会将其传送到handleResult功能,并停止摄像头。如果解码的二维码已经保存在我的应用程序中,我需要重新启动相机。如何重新启动摄像头?如果您使用ZXing的ZXingScannerView在处理二维码和/或向用户显示结果时,可以将stopCameraPreview()与stopCamera()结合使用。当您的应用程序/用户准备再次扫描时,只需使用startCamera()和resumeCameraPreview()调用setResultHandler() 例如:
handleResult
功能,并停止摄像头。如果解码的二维码已经保存在我的应用程序中,我需要重新启动相机。如何重新启动摄像头?如果您使用ZXing的ZXingScannerView
在处理二维码和/或向用户显示结果时,可以将stopCameraPreview()
与stopCamera()
结合使用。当您的应用程序/用户准备再次扫描时,只需使用startCamera()
和resumeCameraPreview()
调用setResultHandler()
例如:
public void startScan() { //use this when you want to resume the camera
if (scannerView != null) {
scannerView.setResultHandler(this);
scannerView.startCamera();
rescan();
}
}
public void stopScan() { //use this when you want to stop scanning
// it is very important to do that,
// because the camera will keep scanning codes in background
if (scannerView != null) {
scannerView.stopCameraPreview();
scannerView.stopCamera();
}
}
public void rescan() {
if (scannerView != null) {
scannerView.resumeCameraPreview(this);
}
}
希望这对您有所帮助:)如果您正在使用ZXing的
ZXingScannerView
您可以在处理二维码和/或向用户显示结果时将stopCameraPreview()
与stopCamera()
结合使用。当您的应用程序/用户准备再次扫描时,只需使用startCamera()
和resumeCameraPreview()
调用setResultHandler()
例如:
public void startScan() { //use this when you want to resume the camera
if (scannerView != null) {
scannerView.setResultHandler(this);
scannerView.startCamera();
rescan();
}
}
public void stopScan() { //use this when you want to stop scanning
// it is very important to do that,
// because the camera will keep scanning codes in background
if (scannerView != null) {
scannerView.stopCameraPreview();
scannerView.stopCamera();
}
}
public void rescan() {
if (scannerView != null) {
scannerView.resumeCameraPreview(this);
}
}
希望这有帮助:)在HandlerResult中,只需检查该值是否存在并重新启动活动…在HandlerResult中,只需检查该值是否存在并重新启动活动。。。