In the project, the device needs to be able to record in the background, but once the app enters the background, the surfaceview will be destroyed. Open the app again and the surfaceview will be re-created. You must execute camera.stopPreview and camera.starPreview in the surfaceCreated() method, otherwise it will The screen will go black. The problem is that if you do this, the recorded video file cannot be played because the camera performs a stopPreview operation in the middle.
Can someone give me some ideas to solve this problem?
Well, it is recommended to use FloatingWindow to achieve the goal of "background recording". Try to hang this surfaceView on the floating window, maximize the floating window when previewing the interface, and once the user exits the application and enters background mode, set the floating window to the size It is a 1-pixel window, and the recording is still running at this time. There is no need to switch the camera state. Naturally, the recorded files will not be sliced.
I don’t know whether this application runs on the phone or on the car device?