Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
559 views
in Technique[技术] by (71.8m points)

android - React-native-camera appears as black screen

I'm trying to implement an eKYC for my application, which included 3 camera screens (2 screens with back side camera, 1 with front side camera)

On some Android devices (Samsung Note 8, Xiaomi Redmi Pro 8, Vsmart Joy 3, ...), the third screen's camera (front side camera) is not working (black screen).

I've tried to read the errors from Android logcat and I receive this error:

2021-01-11 12:29:00.704 3973-13086/com.******.vn W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '8: connectHelper:1648: Too many cameras already open, cannot open camera "1"'

Things I've tried: use NavigationEvents and withNavigationFocus to render the camera when current screen is focused

const [isFocus, setFocus] = useState<boolean>(false)
<NavigationEvents onWillFocus={onFocus} onWillBlur={onBlur}></NavigationEvents>
{isFocus && props.isFocused && (
    <RNCamera
      ref={refCamera}
      style={styles.preview}
      type={RNCamera.Constants.Type.front}
      captureAudio={false}
      onCameraReady={() => console.log('oncameraready')}
      onFacesDetected={onFaceDetected}>
      <View style={styles.progressBarContainer}>
        <Progress.Bar
          color={Colors.asEastOcean}
          progress={progress}
          width={200}
          style={styles.progressBar}
          borderColor={Colors.white}
          unfilledColor={Colors.white}
        />
      </View>
    </RNCamera>
  )}

But the camera on the third screen (front side camera) still not work. The other two work perfectly. Is there any way to fix this, thank you very much in advance!

Note: If I change the order and render the third screen first, the front side camera is working normally.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...