search

Home  >  Q&A  >  body text

android - Problem with device recording in the background

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?

学习ing学习ing2699 days ago1963

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-07-06 10:38:46

    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?

    reply
    0
  • Cancelreply