React-native (React-native-barcodescanner) sweep code The first time in the normal but after the black screen, said on the internet is a new scene to pop out (may be my version and the online version of the different results), But I pop off the second go in or black screen, tangled for a long time, guess is called the camera did not release the cause, but only move Barcodescanner source, looked at the project file directory as follows:
The code for many other locations in the three files in the React-native-barcodescanner project has been modified (in single case mode, Remove the first if method in the Setcameratype method in Reactbarcodescannerview.java, etc., but no, no more, just say the correct way to modify in my environment:
To modify the Setcameratype method in Reactbarcodescannerview.java, the original code:
public void Setcameratype (String type) {
if (mprevcameratype.equals (type)) {
Return
}
Stopcamera ();
Camera.camerainfo camerainfo = new Camera.camerainfo ();
Mcameraid =-1;
for (int cameraid = 0; Cameraid < Camera.getnumberofcameras (); cameraid++) {
Camera.getcamerainfo (Cameraid, camerainfo);
if (Type.equals ("Back") && camerainfo.facing = = Camera.CameraInfo.CAMERA_FACING_BACK) {
Mcameraid = Cameraid;
Break
}
if (Type.equals ("front") && camerainfo.facing = = Camera.CameraInfo.CAMERA_FACING_FRONT) {
Mcameraid = Cameraid;
Break
}
}
Startcamera (Mcameraid);
if (Type.equals ("Back")) {
Setflash (torchmodeisenabled ());
}
Mprevcameratype = type;
}
Modified code:
public void Setcameratype (String type) {
if (mprevcameratype.equals (type)) {
Stopcamera ();
Return
}
Camera.camerainfo camerainfo = new Camera.camerainfo ();
Mcameraid =-1;
for (int cameraid = 0; Cameraid < Camera.getnumberofcameras (); cameraid++) {
Camera.getcamerainfo (Cameraid, camerainfo);
if (Type.equals ("Back") && camerainfo.facing = = Camera.CameraInfo.CAMERA_FACING_BACK) {
Mcameraid = Cameraid;
Break
}
if (Type.equals ("front") && camerainfo.facing = = Camera.CameraInfo.CAMERA_FACING_FRONT) {
Mcameraid = Cameraid;
Break
}
}
Startcamera (Mcameraid);
if (Type.equals ("Back")) {
Setflash (torchmodeisenabled ());
}
Mprevcameratype = type;
}
Above the red Word for the modified code location